Ejemplo n.º 1
0
 public function actionExecute($id)
 {
     ServiceManager::initLogAppend($id, "[OK]");
     $running = true;
     while ($running) {
         if (ServiceManager::hasMsg($id)) {
             $svc = ServiceManager::readMsg($id);
             if (is_array($svc)) {
                 $running = false;
                 $commandPath = Yii::getPathOfAlias($svc['commandPath']);
                 $commandName = lcfirst(substr($svc['command'], 0, strlen($svc['command']) - 7));
                 $actionName = lcfirst(substr($svc['action'], 6));
                 $GLOBALS['svc'] = $svc;
                 $GLOBALS['svc_id'] = $id;
                 ServiceManager::initLog($id, str_pad("Starting {$svc['name']} [PID:{$svc['pid']}]", 45, "."));
                 $runner = new CConsoleCommandRunner();
                 $runner->addCommands($commandPath);
                 $runner->run(['yiic', $commandName, $actionName]);
             }
         }
     }
 }