Ejemplo n.º 1
0
 /**
  * Check file lock, execution time, sync
  */
 public function checkTimeLimit()
 {
     if (!$this->_lock) {
         return;
     }
     $this->_lock->checkTimeLimit($this->getStatString());
 }
Ejemplo n.º 2
0
 /**
  * Launch job  using file lock
  * console command ./console.php /console/[task]/[time limit]/[thread]
  * @param string $name
  * @param string $method
  */
 protected function _launchJob($name, $method = 'run')
 {
     $appCfg = $this->_configs->get($name);
     $time = Request::getInstance()->getPart(2);
     $thread = intval(Request::getInstance()->getPart(3));
     $appCfg['thread'] = $thread;
     if ($time) {
         $this->_cronConfig['time_limit'] = $time;
         $this->_cronConfig['intercept_timeout'] = $time;
     }
     $lock = new Cron_Lock($this->_cronConfig);
     if ($this->_log) {
         $lock->setLogsAdapter($this->_log);
     }
     $adapter = $appCfg['adapter'];
     $config = new Config_Simple($name . '_job');
     $config->setData($appCfg);
     $config->set('lock', $lock);
     $o = new $adapter($config);
     if (!$o->{$method}()) {
         $msg = '1 ' . $name . '_job' . ': error';
     } else {
         $msg = '0 ' . $name . '_job' . ': ' . $o->getStatString();
     }
     $this->_logMessage($msg);
     echo $msg . "\n";
     $lock->finish();
 }
Ejemplo n.º 3
0
 /**
  * Record the message to the lock log
  * @param string $message
  */
 public function log($message)
 {
     parent::log($this->lock->getTaskName() . ' ' . $message);
 }