diff --git a/ciao-launcher/instance.go b/ciao-launcher/instance.go index 49ea10f25..b8c36c5e1 100644 --- a/ciao-launcher/instance.go +++ b/ciao-launcher/instance.go @@ -270,7 +270,7 @@ DONE: case <-id.statsTimer: d, m, c := id.vm.stats() id.ovsCh <- &ovsStatsUpdateCmd{id.instance, m, d, c} - id.statsTimer = time.After(time.Second * statsPeriod) + id.statsTimer = time.After(time.Second * resourcePeriod) case cmd := <-id.cmdCh: if !id.instanceCommand(cmd) { break DONE @@ -296,7 +296,7 @@ DONE: id.ovsCh <- &ovsStateChange{id.instance, ovsRunning} d, m, c := id.vm.stats() id.ovsCh <- &ovsStatsUpdateCmd{id.instance, m, d, c} - id.statsTimer = time.After(time.Second * statsPeriod) + id.statsTimer = time.After(time.Second * resourcePeriod) } } diff --git a/ciao-launcher/main.go b/ciao-launcher/main.go index bc45e03d6..1ec59a950 100644 --- a/ciao-launcher/main.go +++ b/ciao-launcher/main.go @@ -75,12 +75,13 @@ func init() { } const ( - lockDir = "/tmp/lock/ciao" - instancesDir = "/var/lib/ciao/instances" - logDir = "/var/lib/ciao/logs/launcher" - instanceState = "state" - lockFile = "client-agent.lock" - statsPeriod = 30 + lockDir = "/tmp/lock/ciao" + instancesDir = "/var/lib/ciao/instances" + logDir = "/var/lib/ciao/logs/launcher" + instanceState = "state" + lockFile = "client-agent.lock" + statsPeriod = 6 + resourcePeriod = 30 ) type cmdWrapper struct { @@ -527,32 +528,34 @@ func main() { log.Fatalf("Unable to initialise logs: %v", err) } + glog.Info("Starting Launcher") + + exitCode := 0 + var stopProfile func() if profileFN != nil { - stopProfile := profileFN() - if stopProfile != nil { - defer stopProfile() - } + stopProfile = profileFN() } - defer func() { - glog.Flush() - glog.Info("Exit") - }() - - glog.Info("Starting Launcher") - if hardReset { purgeLauncherState() - os.Exit(0) - } + } else { + setLimits() + + glog.Infof("Launcher will allow a maximum of %d instances", maxInstances) - setLimits() + if err := createMandatoryDirs(); err != nil { + glog.Fatalf("Unable to create mandatory dirs: %v", err) + } - glog.Infof("Launcher will allow a maximum of %d instances", maxInstances) + exitCode = startLauncher() + } - if err := createMandatoryDirs(); err != nil { - glog.Fatalf("Unable to create mandatory dirs: %v", err) + if stopProfile != nil { + stopProfile() } - os.Exit(startLauncher()) + glog.Flush() + glog.Info("Exit") + + os.Exit(exitCode) }