pwreset: Stop daemon on restart, dont fail if json is malformed

daemon now stops on the RESTART signal, and when it fails to read JSON,
it no longer stops the whole daemon.
This commit is contained in:
Harvey Tindall
2023-06-11 16:35:41 +01:00
parent d688dd02c8
commit f88f71d933
2 changed files with 6 additions and 3 deletions
+3
View File
@@ -586,11 +586,13 @@ func start(asDaemon, firstCall bool) {
}
}()
for range RESTART {
println("got it too!")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
if err := SRV.Shutdown(ctx); err != nil {
app.err.Fatalf("Server shutdown error: %s", err)
}
app.info.Println("Server shut down.")
return
}
}
@@ -608,6 +610,7 @@ func (app *appContext) shutdown() {
if err := SRV.Shutdown(cntx); err != nil {
app.err.Fatalf("Server shutdown error: %s", err)
}
os.Exit(1)
}
}