示例#1
0
func (master *Master) updateStatus(proc process.ProcContainer) {
	if proc.IsAlive() {
		proc.SetStatus("running")
	} else {
		proc.NotifyStopped()
		proc.SetStatus("stopped")
	}
}
示例#2
0
// NOT thread safe method. Lock should be acquire before calling it.
func (master *Master) start(proc process.ProcContainer) error {
	if !proc.IsAlive() {
		err := proc.Start()
		if err != nil {
			return err
		}
		master.Watcher.AddProcWatcher(proc)
		proc.SetStatus("running")
	}
	return nil
}
示例#3
0
// NOT thread safe method. Lock should be acquire before calling it.
func (master *Master) stop(proc process.ProcContainer) error {
	if proc.IsAlive() {
		waitStop := master.Watcher.StopWatcher(proc.Identifier())
		err := proc.GracefullyStop()
		if err != nil {
			return err
		}
		if waitStop != nil {
			<-waitStop
			proc.NotifyStopped()
			proc.SetStatus("stopped")
		}
		log.Infof("Proc %s successfully stopped.", proc.Identifier())
	}
	return nil
}