Ensure that the pidfile is written after all logic for Barak is

complete.
This commit is contained in:
Jae Kwon 2015-04-24 14:01:22 -07:00
parent e294b1f954
commit 7eefbd23fa
1 changed files with 6 additions and 6 deletions

View File

@ -88,12 +88,6 @@ func main() {
}
barak.registries = options.Registries
// Write pid to file.
err = AtomicWriteFile(barak.rootDir+"/pidfile", []byte(Fmt("%v", barak.pid)))
if err != nil {
panic(Fmt("Error writing pidfile: %v", err))
}
// Debug.
fmt.Printf("Options: %v\n", options)
fmt.Printf("Barak: %v\n", barak)
@ -119,6 +113,12 @@ func main() {
}(registry)
}
// Write pid to file. This should be the last thing before TrapSignal.
err = AtomicWriteFile(barak.rootDir+"/pidfile", []byte(Fmt("%v", barak.pid)))
if err != nil {
panic(Fmt("Error writing pidfile: %v", err))
}
TrapSignal(func() {
fmt.Println("Barak shutting down")
})