taskException() public method

public taskException ( string $serverName, string $exceptionClass, string $message )
$serverName string
$exceptionClass string
$message string
Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function run($tasks, $servers, $environments, $input, $output)
 {
     $output = new OutputWatcher($output);
     $informer = new Informer($output);
     foreach ($tasks as $task) {
         $success = true;
         $informer->startTask($task->getName());
         if ($task->isOnce()) {
             $task->run(new Context(null, null, $input, $output));
         } else {
             foreach ($servers as $serverName => $server) {
                 if ($task->runOnServer($serverName)) {
                     $env = isset($environments[$serverName]) ? $environments[$serverName] : ($environments[$serverName] = new Environment());
                     $informer->onServer($serverName);
                     try {
                         $task->run(new Context($server, $env, $input, $output));
                     } catch (NonFatalException $exception) {
                         $success = false;
                         $informer->taskException($serverName, 'Deployer\\Task\\NonFatalException', $exception->getMessage());
                     }
                     $informer->endOnServer($serverName);
                 }
             }
         }
         if ($success) {
             $informer->endTask();
         } else {
             $informer->taskError();
         }
     }
 }
Beispiel #2
0
 /**
  * Wait for exceptions from workers.
  */
 public function catchExceptions()
 {
     while (count($this->exceptionStorage) > 0) {
         list($serverName, $exceptionClass, $message) = $this->exceptionStorage->pop();
         // Print exception message.
         $this->informer->taskException($serverName, $exceptionClass, $message);
         // We got some exception, so not.
         $this->isSuccessfullyFinished = false;
         if ($exceptionClass == 'Deployer\\Task\\NonFatalException') {
             // If we got NonFatalException, continue other tasks.
             $this->hasNonFatalException = true;
         } else {
             // Do not run other task.
             // Finish all current worker tasks and stop loop.
             $this->tasks = [];
             // Worker will not mark this task as done (remove self server name from `tasks_to_do` list),
             // so to finish current task execution we need to manually remove it from that list.
             $taskToDoStorage = $this->pure->getStorage('tasks_to_do');
             $taskToDoStorage->delete($serverName);
         }
     }
 }