From b25deaacea75f2e565a58ea14aca19627f5cfa93 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:24:02 -0800 Subject: queue daemon fixes: path fix for xmpp, suppress warning in memcached init --- lib/xmppmanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 9662e97d1..0839cda57 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -81,7 +81,7 @@ class XmppManager extends IoManager parent::start($master); $this->switchSite(); - require_once "lib/jabber.php"; + require_once INSTALLDIR . "/lib/jabber.php"; # Low priority; we don't want to receive messages -- cgit v1.2.3-54-g00ecf From 4b839cfc53d1aa5aa64adb940e122efe1475c9e9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:35:47 -0800 Subject: fix for non-% memory soft limit --- lib/iomaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/iomaster.php b/lib/iomaster.php index aff5b145c..5d1071a39 100644 --- a/lib/iomaster.php +++ b/lib/iomaster.php @@ -231,7 +231,7 @@ class IoMaster return -1; } } else { - return $this->parseMemoryLimit($limit); + return $this->parseMemoryLimit($softLimit); } return $softLimit; } -- cgit v1.2.3-54-g00ecf From 8a7171fde610246e5820ee04441955bd8dd463bf Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 23:38:51 -0800 Subject: Don't barf on io loop if xmpp connection failed --- lib/xmppmanager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 0839cda57..dfff63a30 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -118,7 +118,11 @@ class XmppManager extends IoManager */ public function getSockets() { - return array($this->conn->getSocket()); + if ($this->conn) { + return array($this->conn->getSocket()); + } else { + return array(); + } } /** -- cgit v1.2.3-54-g00ecf From 2f32181c930afbbfad7986f84df908cac4ef182d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 00:19:25 -0800 Subject: Keep handler registration per-site to fix queue registration in mixed config environment --- lib/stompqueuemanager.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'lib') diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 3090e0bfb..a7d735d1c 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -66,10 +66,57 @@ class StompQueueManager extends QueueManager * * @fixme possibly actually do subscription here to save another * loop over all sites later? + * @fixme possibly don't assume it's the current site */ public function addSite($server) { $this->sites[] = $server; + $this->initialize(); + } + + + /** + * Instantiate the appropriate QueueHandler class for the given queue. + * + * @param string $queue + * @return mixed QueueHandler or null + */ + function getHandler($queue) + { + $handlers = $this->handlers[common_config('site', 'server')]; + if (isset($handlers[$queue])) { + $class = $handlers[$queue]; + if (class_exists($class)) { + return new $class(); + } else { + common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'"); + } + } else { + common_log(LOG_ERR, "Requested handler for unkown queue '$queue'"); + } + return null; + } + + /** + * Get a list of all registered queue transport names. + * + * @return array of strings + */ + function getQueues() + { + return array_keys($this->handlers[common_config('site', 'server')]); + } + + /** + * Register a queue transport name and handler class for your plugin. + * Only registered transports will be reliably picked up! + * + * @param string $transport + * @param string $class + */ + public function connect($transport, $class) + { + $this->handlers[common_config('site', 'server')][$transport] = $class; } /** -- cgit v1.2.3-54-g00ecf From 58bc33850ab615f21b4364aac8b8b7f74a95111d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 15:32:37 -0800 Subject: temporary --skip-xmpp flag on queuedaemon.php, allows to run queue daemons but skip subscription to xmpp-based queues (still working on making these behave gracefully when server is down) --- lib/queuemanager.php | 2 +- scripts/queuedaemon.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/queuemanager.php b/lib/queuemanager.php index a98c0efff..b98e57a1f 100644 --- a/lib/queuemanager.php +++ b/lib/queuemanager.php @@ -157,7 +157,7 @@ abstract class QueueManager extends IoManager } // XMPP output handlers... - if (common_config('xmpp', 'enabled')) { + if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) { $this->connect('jabber', 'JabberQueueHandler'); $this->connect('public', 'PublicQueueHandler'); diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php index 8ef364fe7..f8bade39d 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='); +$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp'); /** * Attempts to get a count of the processors available on the current system @@ -260,6 +260,10 @@ 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); +} + $daemon = new QueueDaemon($id, $daemonize, $threads, $all); $daemon->runOnce(); -- cgit v1.2.3-54-g00ecf From 038287c1ffb71207f8028014f20005483364956d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 17:14:41 -0800 Subject: fix for --skip-xmpp hack -- forgot to do it on the ping & confirm handlers --- lib/iomaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/iomaster.php b/lib/iomaster.php index 5d1071a39..ce77b53b2 100644 --- a/lib/iomaster.php +++ b/lib/iomaster.php @@ -70,7 +70,7 @@ class IoMaster $classes = array(); if (Event::handle('StartIoManagerClasses', array(&$classes))) { $classes[] = 'QueueManager'; - if (common_config('xmpp', 'enabled')) { + if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) { $classes[] = 'XmppManager'; // handles pings/reconnects $classes[] = 'XmppConfirmManager'; // polls for outgoing confirmations } -- cgit v1.2.3-54-g00ecf