From e9995b0f6ab0788162e22c996e5ee0af416dd519 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 23 Jan 2010 01:25:27 -0500 Subject: Create IM plugin, Pluginize XMPP, Create AIM plugin --- scripts/getvaliddaemons.php | 4 +- scripts/imdaemon.php | 93 ++++++++++++++++++++++++++++++++++++++++++ scripts/queuedaemon.php | 9 +---- scripts/stopdaemons.sh | 4 +- scripts/xmppdaemon.php | 98 --------------------------------------------- 5 files changed, 97 insertions(+), 111 deletions(-) create mode 100755 scripts/imdaemon.php delete mode 100755 scripts/xmppdaemon.php (limited to 'scripts') diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index a332e06b5..80c21bce5 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -39,9 +39,7 @@ $daemons = array(); $daemons[] = INSTALLDIR.'/scripts/queuedaemon.php'; -if(common_config('xmpp','enabled')) { - $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; -} +$daemons[] = INSTALLDIR.'/scripts/imdaemon.php'; if (Event::handle('GetValidDaemons', array(&$daemons))) { foreach ($daemons as $daemon) { diff --git a/scripts/imdaemon.php b/scripts/imdaemon.php new file mode 100755 index 000000000..c37a26b7c --- /dev/null +++ b/scripts/imdaemon.php @@ -0,0 +1,93 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'fi::'; +$longoptions = array('id::', 'foreground'); + +$helptext = <<get_id()); + $master->init(); + $master->service(); + + common_log(LOG_INFO, 'terminating normally'); + + return true; + } + +} + +class ImMaster extends IoMaster +{ + /** + * Initialize IoManagers for the currently configured site + * which are appropriate to this instance. + */ + function initManagers() + { + $classes = array(); + if (Event::handle('StartImDaemonIoManagers', array(&$classes))) { + $classes[] = 'QueueManager'; + } + Event::handle('EndImDaemonIoManagers', array(&$classes)); + foreach ($classes as $class) { + $this->instantiate($class); + } + } +} + +if (have_option('i', 'id')) { + $id = get_option_value('i', 'id'); +} else if (count($args) > 0) { + $id = $args[0]; +} else { + $id = null; +} + +$foreground = have_option('f', 'foreground'); + +$daemon = new ImDaemon($id, !$foreground); + +$daemon->runOnce(); diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php index a9cfda6d7..bedd14b1a 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 @@ -163,13 +163,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(); diff --git a/scripts/stopdaemons.sh b/scripts/stopdaemons.sh index c790f1f34..bc1230e64 100755 --- a/scripts/stopdaemons.sh +++ b/scripts/stopdaemons.sh @@ -23,8 +23,8 @@ SDIR=`dirname $0` DIR=`php $SDIR/getpiddir.php` -for f in jabberhandler ombhandler publichandler smshandler pinghandler \ - xmppconfirmhandler xmppdaemon twitterhandler facebookhandler \ +for f in ombhandler smshandler pinghandler \ + twitterhandler facebookhandler \ twitterstatusfetcher synctwitterfriends pluginhandler rsscloudhandler; do FILES="$DIR/$f.*.pid" diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php deleted file mode 100755 index fd7cf055b..000000000 --- a/scripts/xmppdaemon.php +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env php -. - */ - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); - -$shortoptions = 'fi::'; -$longoptions = array('id::', 'foreground'); - -$helptext = <<get_id()); - $master->init(); - $master->service(); - - common_log(LOG_INFO, 'terminating normally'); - - return true; - } - -} - -class XmppMaster extends IoMaster -{ - /** - * Initialize IoManagers for the currently configured site - * which are appropriate to this instance. - */ - function initManagers() - { - // @fixme right now there's a hack in QueueManager to determine - // which queues to subscribe to based on the master class. - $this->instantiate('QueueManager'); - $this->instantiate('XmppManager'); - } -} - -// Abort immediately if xmpp is not enabled, otherwise the daemon chews up -// lots of CPU trying to connect to unconfigured servers -if (common_config('xmpp','enabled')==false) { - print "Aborting daemon - xmpp is disabled\n"; - exit(); -} - -if (have_option('i', 'id')) { - $id = get_option_value('i', 'id'); -} else if (count($args) > 0) { - $id = $args[0]; -} else { - $id = null; -} - -$foreground = have_option('f', 'foreground'); - -$daemon = new XMPPDaemon($id, !$foreground); - -$daemon->runOnce(); -- cgit v1.2.3-54-g00ecf