Skip to content

Commit

Permalink
Merge pull request ciao-project#348 from markdryan/master
Browse files Browse the repository at this point in the history
ciao-launcher: Update statistics interval and fix profiling
  • Loading branch information
kaccardi authored Jul 12, 2016
2 parents b423f16 + 31a9688 commit 373c505
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions ciao-launcher/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

Expand Down
51 changes: 27 additions & 24 deletions ciao-launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 373c505

Please sign in to comment.