Beispiel #1
0
func (self *ShellExecutor) OnKillTask(driver *mesos.ExecutorDriver, tid mesos.TaskID) {
	taskId := tid.GetValue()
	log.Warningf("OnKillTask %s", taskId)
	self.lock.Lock()
	defer self.lock.Unlock()
	if cmd, ok := self.process[taskId]; ok {
		err := cmd.Process.Kill()
		if err != nil {
			log.Errorf("kill taskId %s failed, err:%v", taskId, err)
		}
	}

	log.Error("send kill state")
	self.sendStatusUpdate(tid.GetValue(), mesos.TaskState_TASK_KILLED, "task killed by framework!")
}
Beispiel #2
0
func (self *ShellExecutor) OnKillTask(driver *mesos.ExecutorDriver, tid mesos.TaskID) {
	taskId := tid.GetValue()
	log.Warningf("OnKillTask %s", taskId)
	self.lock.Lock()
	defer self.lock.Unlock()
	if contex, ok := self.process[taskId]; ok {
		ret, _ := exec.Command("pgrep", "-P", strconv.Itoa(contex.cmd.Process.Pid)).Output()
		log.Debug("children process", string(ret))
		log.Debug("pid", contex.cmd.Process.Pid)
		ret, err := exec.Command("pkill", "-P", strconv.Itoa(contex.cmd.Process.Pid)).Output()
		if err != nil {
			log.Errorf("kill taskId %s failed, err:%v", taskId, err)
		}
		log.Debugf("kill taskId %s result %v", taskId, ret)
		contex.statusFile.Stop()
	}

	//log.Error("send kill state")
	//self.sendStatusUpdate(tid.GetValue(), mesos.TaskState_TASK_KILLED, "")
}