cmd/stepd: Fix pid file being spawned even if not specified

This commit is contained in:
Sasha Koshka 2024-12-10 02:58:50 -05:00
parent 666a9b0c77
commit 4a1b78b857

View File

@ -59,11 +59,11 @@ func main () {
ctx, done := context.WithCancel(context.Background()) ctx, done := context.WithCancel(context.Background())
defer done() defer done()
daemon.OnSigint(done) daemon.OnSigint(done)
pidFileAbs, err := filepath.Abs(flagPidFile.Value) if flagPidFile.Value != "" {
if err != nil { log.Fatalln("XXX", err) } pidFileAbs, err := filepath.Abs(flagPidFile.Value)
pidFile := daemon.PidFile(pidFileAbs) if err != nil { log.Fatalln("XXX", err) }
if !pidFile.Empty() { pidFile := daemon.PidFile(pidFileAbs)
err := pidFile.Start() err = pidFile.Start()
if err != nil { log.Println("!!! could not write pid:", err) } if err != nil { log.Println("!!! could not write pid:", err) }
defer func () { defer func () {
err := pidFile.Close() err := pidFile.Close()
@ -111,7 +111,7 @@ func main () {
Config: config, Config: config,
} }
environment.Providers = providers.All() environment.Providers = providers.All()
err = environment.Init(context.Background()) err := environment.Init(context.Background())
if err != nil { log.Fatal(err) } if err != nil { log.Fatal(err) }
// set up the HTTP handler // set up the HTTP handler