Add automatic upgrades for spn-hub

This commit is contained in:
Daniel
2020-08-11 07:55:26 +02:00
parent 6ded9b3f8c
commit 092da058a5
3 changed files with 112 additions and 17 deletions

View File

@@ -5,12 +5,12 @@ import (
"github.com/safing/portbase/log"
"github.com/safing/portbase/modules"
"github.com/safing/portmaster/updates"
)
const (
eventShutdown = "shutdown"
eventRestart = "restart"
restartCode = 23
)
func registerEvents() {
@@ -43,7 +43,7 @@ func shutdown(ctx context.Context, _ interface{}) error {
// restart restarts the Portmaster.
func restart(ctx context.Context, data interface{}) error {
log.Info("core: user requested restart")
modules.SetExitStatusCode(restartCode)
modules.SetExitStatusCode(updates.RestartExitCode)
// Do not use a worker, as this would block itself here.
go modules.Shutdown() //nolint:errcheck
return nil