diff --git a/cmd/router/main.go b/cmd/router/main.go index 34d73c5..37e041d 100644 --- a/cmd/router/main.go +++ b/cmd/router/main.go @@ -76,16 +76,16 @@ func main () { } // be a daemon - daemon.ShutdownOnSigint() + daemon.ShutdownOnSigint(&manager) pidfile := daemon.PidFile(os.Getenv("HNAKRA_PIDFILE")) if !pidfile.Empty() { err := pidfile.Start() if err != nil { log.Println("!!! could not write pid:", err) } + defer func () { + err := pidfile.Close() + if err != nil { log.Println("!!! could not delete pidfile:", err) } + } () } - defer func () { - err := pidfile.Close() - if err != nil { log.Println("!!! could not delete pidfile:", err) } - } () // run servers err = manager.Run()