Exemplo n.º 1
0
 public function actionRestart()
 {
     echo "start restart..\n";
     $task = 'manager/restart';
     $num = System::getProcessNum($task);
     if ($num > 0) {
         return true;
     }
     while ($this->try < $this->tryLimit) {
         $this->try++;
         $status = System::startByRoot(CRONTAB_ROOT . '/yii', $task, 1);
         if ($status) {
             echo "restart {$task}\n";
             break;
         }
     }
     echo "restarted..\n";
 }
Exemplo n.º 2
0
 protected function check()
 {
     foreach ($this->tasks as $key => $item) {
         $task = $item[0];
         $num = $item[1];
         $runType = $item[2];
         $state = $item[3];
         if (!$state || $runType && !IS_MASTER) {
             unset($this->tasks[$key]);
             continue;
         }
         $current = System::getProcessNum($task);
         $num -= $current;
         if ($num > 0) {
             $msg = sprintf("[%s] %s ", date('Y-m-d H:i:s'), "start {$task}");
             if (System::start(CRONTAB_ROOT . '/yii', $task, $num, '/dev/null', '')) {
                 $this->log("start {$msg} ok");
             } else {
                 $this->log("start {$msg} fail");
             }
         }
     }
 }