X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fqueuedaemon.php;h=bdd630f3d5a2e6ef54c8ff3982a5fe7d8a27977b;hb=d9b35208ecda59292680fb55e38c56b2831d5366;hp=a9cfda6d72e8f927ee513fe8572a26ccde00c96c;hpb=ef3b849db05ff6ad4b9e97b38a82242a710519d1;p=quix0rs-gnu-social.git diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php index a9cfda6d72..bdd630f3d5 100755 --- a/scripts/queuedaemon.php +++ b/scripts/queuedaemon.php @@ -21,7 +21,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'fi:at:'; -$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp', 'xmpp-only'); +$longoptions = array('id=', 'foreground', 'all', 'threads='); /** * Attempts to get a count of the processors available on the current system @@ -68,14 +68,12 @@ Daemon script for running queued items. END_OF_QUEUE_HELP; -require_once INSTALLDIR.'/scripts/commandline.inc'; +require_once INSTALLDIR.'/scripts/commandline.inc.php'; require_once(INSTALLDIR.'/lib/daemon.php'); require_once(INSTALLDIR.'/classes/Queue_item.php'); require_once(INSTALLDIR.'/classes/Notice.php'); -define('CLAIM_TIMEOUT', 1200); - /** * Queue handling daemon... * @@ -92,7 +90,7 @@ class QueueDaemon extends SpawningDaemon function __construct($id=null, $daemonize=true, $threads=1, $allsites=false) { parent::__construct($id, $daemonize, $threads); - $this->all = $allsites; + $this->allsites = $allsites; } /** @@ -107,34 +105,50 @@ class QueueDaemon extends SpawningDaemon { $this->log(LOG_INFO, 'checking for queued notices'); - $master = new QueueMaster($this->get_id()); - $master->init($this->all); - $master->service(); + $master = new QueueMaster($this->get_id(), $this->processManager()); + $master->init($this->allsites); + try { + $master->service(); + } catch (Exception $e) { + common_log(LOG_ERR, "Unhandled exception: " . $e->getMessage() . ' ' . + str_replace("\n", " ", $e->getTraceAsString())); + return self::EXIT_ERR; + } $this->log(LOG_INFO, 'finished servicing the queue'); $this->log(LOG_INFO, 'terminating normally'); - return true; + return $master->respawn ? self::EXIT_RESTART : self::EXIT_SHUTDOWN; } } class QueueMaster extends IoMaster { + protected $processManager; + + function __construct($id, $processManager) + { + parent::__construct($id); + $this->processManager = $processManager; + } + /** - * Initialize IoManagers for the currently configured site - * which are appropriate to this instance. + * Initialize IoManagers which are appropriate to this instance. */ function initManagers() { - $classes = array(); - if (Event::handle('StartQueueDaemonIoManagers', array(&$classes))) { - $classes[] = 'QueueManager'; + $managers = array(); + if (Event::handle('StartQueueDaemonIoManagers', array(&$managers))) { + $qm = QueueManager::get(); + $qm->setActiveGroup('main'); + $managers[] = $qm; + $managers[] = $this->processManager; } - Event::handle('EndQueueDaemonIoManagers', array(&$classes)); + Event::handle('EndQueueDaemonIoManagers', array(&$managers)); - foreach ($classes as $class) { - $this->instantiate($class); + foreach ($managers as $manager) { + $this->instantiate($manager); } } } @@ -163,13 +177,6 @@ if (!$threads) { $daemonize = !(have_option('f') || have_option('--foreground')); $all = have_option('a') || have_option('--all'); -if (have_option('--skip-xmpp')) { - define('XMPP_EMERGENCY_FLAG', true); -} -if (have_option('--xmpp-only')) { - define('XMPP_ONLY_FLAG', true); -} - $daemon = new QueueDaemon($id, $daemonize, $threads, $all); $daemon->runOnce();