// 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()) } }
// Stop all async processes the Agent is running func (a *Agent) Stop() { log.Info("Stopping Agent") close(a.stop) }
func (e *Engine) Stop() { log.Info("Stopping Engine") close(e.stop) }