mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +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
|
// NewContext() will use this DataStore for the web handlers
|
||||||
DataStore = ds
|
DataStore = ds
|
||||||
|
|
||||||
// TODO Make configurable
|
|
||||||
if cfg.CookieAuthKey == "" {
|
if cfg.CookieAuthKey == "" {
|
||||||
log.Infof("HTTP generating random cookie.auth.key")
|
log.Infof("HTTP generating random cookie.auth.key")
|
||||||
sessionStore = sessions.NewCookieStore(securecookie.GenerateRandomKey(64))
|
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)
|
log.Infof("Inbucket %v (%v) starting...", config.Version, config.BuildDate)
|
||||||
|
|
||||||
// Write pidfile if requested
|
// Write pidfile if requested
|
||||||
// TODO: Probably supposed to remove pidfile during shutdown
|
|
||||||
if *pidfile != "none" {
|
if *pidfile != "none" {
|
||||||
pidf, err := os.Create(*pidfile)
|
pidf, err := os.Create(*pidfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to create %v: %v", *pidfile, err)
|
log.Errorf("Failed to create %q: %v", *pidfile, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(pidf, "%v\n", os.Getpid())
|
fmt.Fprintf(pidf, "%v\n", os.Getpid())
|
||||||
if err := pidf.Close(); err != nil {
|
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
|
// Wait for active connections to finish
|
||||||
smtpServer.Drain()
|
smtpServer.Drain()
|
||||||
pop3Server.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
|
// openLogFile creates or appends to the logfile passed on commandline
|
||||||
|
|||||||
Reference in New Issue
Block a user