public function __construct() { parent::__construct(); if (!empty($GLOBALS['sugar_config']['job_server'])) { $this->jobserver = $GLOBALS['sugar_config']['job_server']; } $this->setClient(new SugarHttpClient()); }
protected function forkJob($job) { DBManagerFactory::disconnectAll(); $pid = pcntl_fork(); if ($pid) { // parent - reconnect and exit $GLOBALS['db'] = DBManagerFactory::getInstance(); $GLOBALS['log']->debug('After fork - parent'); return; } else { // the child process $GLOBALS['log']->debug('After fork - child'); $sid = posix_setsid(); if ($sid < 0) { $this->fail($job, "Could not change session ID"); } // Reestablish DB connections after fork $GLOBALS['db'] = DBManagerFactory::getInstance(); parent::executeJob($job); $this->job = null; exit(0); } }