Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: truncating novm binary before making sure update exists or not #4

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions update_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
"log"
"net/http"
"os"
"os/signal"
"path/filepath"
"runtime"
"syscall"

"golang.org/x/mod/semver"

Expand Down Expand Up @@ -123,12 +125,32 @@ func startCheckUpdate() (chan bool, chan bool) {
}
}

} else {
<-cont // consume
log.Println("no new novm updates found.")
return
}

// we ignore sigint and sigterm here to not lose the binary

sig := make(chan os.Signal, 1)

signal.Notify(sig, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT)

go func() {
for {
<-sig

log.Println("ignoring signal since novm is still updating")
}
}()

<-cont // upgrade the binary

// we expect current binary to be a symlink

log.Printf("Updating novm to %s", release.Tag)

root, _ := common.RootDir()

bin := filepath.Join(root, "bin", "node")
Expand Down