diff --git a/fleetd/fleet.go b/fleetd/fleet.go index bfaa2e1c5..cdf55a7f3 100644 --- a/fleetd/fleet.go +++ b/fleetd/fleet.go @@ -23,6 +23,7 @@ import ( "os" "os/signal" "strings" + "sync" "syscall" "github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/globalconf" @@ -85,7 +86,11 @@ func main() { } srv.Run() + srvMutex := sync.Mutex{} + reconfigure := func() { + srvMutex.Lock() + defer srvMutex.Unlock() log.Infof("Reloading configuration from %s", *cfgPath) cfg, err := getConfig(cfgset, *cfgPath) @@ -105,12 +110,16 @@ func main() { shutdown := func() { log.Infof("Gracefully shutting down") + srvMutex.Lock() + defer srvMutex.Unlock() srv.Stop() srv.Purge() os.Exit(0) } writeState := func() { + srvMutex.Lock() + defer srvMutex.Unlock() log.Infof("Dumping server state") encoded, err := json.Marshal(srv)