Пример #1
0
func (master *Master) updateStatus(proc *process.Proc) {
	if proc.IsAlive() {
		proc.Status.SetStatus("running")
	} else {
		proc.Pid = -1
		proc.Status.SetStatus("stopped")
	}
}
Пример #2
0
// NOT thread safe method. Lock should be acquire before calling it.
func (master *Master) start(proc *process.Proc) error {
	if !proc.IsAlive() {
		err := proc.Start()
		if err != nil {
			return err
		}
		master.Watcher.AddProcWatcher(proc)
		proc.Status.SetStatus("running")
	}
	return nil
}
Пример #3
0
// NOT thread safe method. Lock should be acquire before calling it.
func (master *Master) stop(proc *process.Proc) error {
	if proc.IsAlive() {
		waitStop := master.Watcher.StopWatcher(proc.Name)
		err := proc.GracefullyStop()
		if err != nil {
			return err
		}
		if waitStop != nil {
			<-waitStop
			proc.Pid = -1
			proc.Status.SetStatus("stopped")
		}
		log.Infof("Proc %s sucessfully stopped.", proc.Name)
	}
	return nil
}