示例#1
0
文件: agent.go 项目: paulczar/fleet
// Purge removes the Agent's state from the Registry
func (a *Agent) Purge() {
	// Continue heartbeating the agent's machine state while attempting to
	// stop all the locally-running jobs
	purged := make(chan bool)
	go a.heartbeatAgent(a.ttl, purged)

	a.state.Lock()
	scheduled := a.state.ScheduledJobs()
	a.state.Unlock()

	machID := a.Machine.State().ID
	for _, jobName := range scheduled {
		log.Infof("Unloading Job(%s) from local machine", jobName)
		a.unloadJob(jobName)
		log.Infof("Unscheduling Job(%s) from local machine", jobName)
		a.registry.ClearJobTarget(jobName, machID)
	}

	// Jobs have been stopped, the heartbeat can stop
	close(purged)

	log.Info("Removing Agent from Registry")
	if err := a.registry.RemoveMachineState(machID); err != nil {
		log.Errorf("Failed to remove Machine %s from Registry: %s", machID, err.Error())
	}
}
示例#2
0
文件: agent.go 项目: rswart/fleet
// Stop all async processes the Agent is running
func (a *Agent) Stop() {
	log.Info("Stopping Agent")
	close(a.stop)
}
示例#3
0
文件: engine.go 项目: rswart/fleet
func (e *Engine) Stop() {
	log.Info("Stopping Engine")
	close(e.stop)
}