mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
Remove PID file during shutdown
This commit is contained in:
@@ -41,7 +41,6 @@ func Initialize(cfg config.WebConfig, ds smtpd.DataStore) {
|
||||
// NewContext() will use this DataStore for the web handlers
|
||||
DataStore = ds
|
||||
|
||||
// TODO Make configurable
|
||||
if cfg.CookieAuthKey == "" {
|
||||
log.Infof("HTTP generating random cookie.auth.key")
|
||||
sessionStore = sessions.NewCookieStore(securecookie.GenerateRandomKey(64))
|
||||
|
||||
12
inbucket.go
12
inbucket.go
@@ -107,16 +107,15 @@ func main() {
|
||||
log.Infof("Inbucket %v (%v) starting...", config.Version, config.BuildDate)
|
||||
|
||||
// Write pidfile if requested
|
||||
// TODO: Probably supposed to remove pidfile during shutdown
|
||||
if *pidfile != "none" {
|
||||
pidf, err := os.Create(*pidfile)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to create %v: %v", *pidfile, err)
|
||||
log.Errorf("Failed to create %q: %v", *pidfile, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintf(pidf, "%v\n", os.Getpid())
|
||||
if err := pidf.Close(); err != nil {
|
||||
log.Errorf("Failed to close PID file %v: %v", *pidfile, err)
|
||||
log.Errorf("Failed to close PID file %q: %v", *pidfile, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +139,13 @@ func main() {
|
||||
// Wait for active connections to finish
|
||||
smtpServer.Drain()
|
||||
pop3Server.Drain()
|
||||
|
||||
// Remove pidfile
|
||||
if *pidfile != "none" {
|
||||
if err := os.Remove(*pidfile); err != nil {
|
||||
log.Errorf("Failed to remove %q: %v", *pidfile, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// openLogFile creates or appends to the logfile passed on commandline
|
||||
|
||||
Reference in New Issue
Block a user