Skip to content

Commit

Permalink
Merge pull request #4 from debdutdeb/fix/skip-when-no-newer-versions
Browse files Browse the repository at this point in the history
fix: truncating novm binary before making sure update exists or not
  • Loading branch information
debdutdeb authored Mar 21, 2024
2 parents d6ac0b2 + 1a25af3 commit 601f2a6
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit 601f2a6

Please # to comment.