Ejemplo n.º 1
0
 /**
  * Dispatch command
  *
  * @param $command
  */
 protected function dispatch($task)
 {
     $this->emit('execute', $task);
     $that = $this;
     $this->process->parallel(function () use($task, $that) {
         $status = Utils::exec($task->command, $stdout, $stderr);
         $that->emit('executed', $task, array($status, $stdout, $stderr));
     });
 }
Ejemplo n.º 2
0
 public function log(array $message = array())
 {
     $fields = array('crontab_id' => '0', 'hostname' => Utils::hostname(), 'cron_name' => '', 'status' => '0', 'stdout' => '', 'stderr' => '', 'create_time' => date('Y-m-d H:i:s'));
     $message = $message + $fields;
     $keys = implode('`, `', array_keys($message));
     $values = trim(str_pad("", 3 * count($message), ", ?"), ' ,');
     try {
         if (FALSE === $this->pdo->query('SELECT 1')) {
             self::connect();
         }
     } catch (PDOException $e) {
         self::connect();
     }
     $sql = sprintf("/* file:%s line: %d */INSERT INTO `%s` (`%s`) values (%s)", __FILE__, __LINE__, $this->options['log_table'], $keys, $values);
     $sth = $this->pdo->prepare($sql);
     $sth->execute(array_values($message));
 }