diff --git a/ciao-launcher/main.go b/ciao-launcher/main.go index 894660a9f..1ec59a950 100644 --- a/ciao-launcher/main.go +++ b/ciao-launcher/main.go @@ -528,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) }