예제 #1
0
 /**
  * @return null|int
  */
 public function getId()
 {
     if ($this->task instanceof Process) {
         return $this->task->getId();
     }
     return null;
 }
예제 #2
0
 /**
  * Revoke any background processes attached to this task.
  *
  * @param Task $task
  *
  * @return bool
  */
 private function killTask(Task $task)
 {
     if ($task instanceof Process) {
         $stdout = $this->getStdOut();
         $stderr = $this->getStdErr();
         $this->getShell()->exec("kill -9 %s {$stdout} {$stderr} &", [$task->getId()]);
         return true;
     }
     return false;
 }
예제 #3
0
 /**
  * Revoke any background processes attached to this task.
  *
  * @param Task $task
  *
  * @return bool
  */
 private function killTask(Task $task)
 {
     if ($task instanceof Process) {
         $this->getShell()->exec("kill -9 %s", [$task->getId()]);
         return true;
     }
     return false;
 }
예제 #4
0
 /**
  * Checks whether a running process can be removed (has stopped running).
  *
  * @param Task $task
  *
  * @return bool
  */
 protected function canRemoveTask(Task $task)
 {
     if (!$task instanceof Process) {
         return true;
     }
     $processes = array_filter($this->running, function (Task $task) {
         return $task instanceof Process;
     });
     if (count($processes) < 1) {
         return true;
     }
     $found = false;
     $stats = $this->getStatsForProcesses($processes);
     foreach ($stats as $stat) {
         if ($stat[0] === $task->getId()) {
             $found = true;
         }
     }
     return !$found;
 }
예제 #5
0
 /**
  * Revoke any background processes attached to this task
  *
  * @param Task $task
  * @return bool If the process was killed
  */
 protected function killTask(Task $task)
 {
     if ($task instanceof Process) {
         $this->getShell()->exec("kill -9 %s", array($task->getId()));
         return true;
     }
     return false;
 }