--xmpp-only hack for queuedaemon.php to run separate queue daemon with only xmpp threads

This commit is contained in:
Brion Vibber 2010-01-15 11:13:06 -08:00
parent 963260d262
commit 598072468c
3 changed files with 24 additions and 10 deletions

View File

@ -149,12 +149,14 @@ abstract class QueueManager extends IoManager
function initialize()
{
if (Event::handle('StartInitializeQueueManager', array($this))) {
if (!defined('XMPP_ONLY_FLAG')) { // hack!
$this->connect('plugin', 'PluginQueueHandler');
$this->connect('omb', 'OmbQueueHandler');
$this->connect('ping', 'PingQueueHandler');
if (common_config('sms', 'enabled')) {
$this->connect('sms', 'SmsQueueHandler');
}
}
// XMPP output handlers...
if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) {
@ -165,11 +167,15 @@ abstract class QueueManager extends IoManager
$this->connect('confirm', 'XmppConfirmHandler');
}
if (!defined('XMPP_ONLY_FLAG')) { // hack!
// For compat with old plugins not registering their own handlers.
$this->connect('plugin', 'PluginQueueHandler');
}
}
if (!defined('XMPP_ONLY_FLAG')) { // hack!
Event::handle('EndInitializeQueueManager', array($this));
}
}
/**
* Register a queue transport name and handler class for your plugin.

View File

@ -104,7 +104,12 @@ class StompQueueManager extends QueueManager
*/
function getQueues()
{
return array_keys($this->handlers[common_config('site', 'server')]);
$site = common_config('site', 'server');
if (empty($this->handlers[$site])) {
return array();
} else {
return array_keys($this->handlers[$site]);
}
}
/**

View File

@ -21,7 +21,7 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'fi:at:';
$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp');
$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp', 'xmpp-only');
/**
* Attempts to get a count of the processors available on the current system
@ -263,6 +263,9 @@ $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();