Example #1
0
 /**
  * @inheritDoc
  */
 public function startup()
 {
     if ($this->command !== 'main') {
         parent::startup();
         return;
     }
     $this->loadModel('DelayedJobs.Workers');
     $this->_myPID = getmypid();
     $this->_hostName = php_uname('n');
     $this->_startTime = time();
     $worker_count = $this->Workers->find()->where(['host_name' => $this->_hostName, 'status in' => [WorkersTable::STATUS_RUNNING, WorkersTable::STATUS_SHUTDOWN, WorkersTable::STATUS_TO_KILL]])->count();
     $this->_workerName = $this->_hostName . '-' . $worker_count;
     $this->_worker = $this->Workers->started($this->_hostName, $this->_workerName, $this->_myPID);
     $this->_workerId = $this->_workerName . '.' . $this->_workerName;
     $this->_suicideMode = Configure::read('DelayedJobs.workers.suicideMode') + $this->_suicideMode;
     $this->_timeOfLastJob = microtime(true);
     cli_set_process_title(sprintf('DJ Worker :: %s :: Booting', $this->_workerId));
     $this->_enableListeners();
     parent::startup();
 }