summaryrefslogtreecommitdiff
path: root/scripts/xmppdaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-28 16:13:08 -0400
committerEvan Prodromou <evan@controlyourself.ca>2009-06-28 16:13:08 -0400
commit47e1d2adb87ae8ffa4c954d3ba62da64e986696c (patch)
tree6e649f6e234c0f996de28d71b2cd3e9c82c00128 /scripts/xmppdaemon.php
parent2f8c656e1df10984527fe445bd57783f5fdcafdc (diff)
xmppdaemon.php can stay in foreground
Diffstat (limited to 'scripts/xmppdaemon.php')
-rwxr-xr-xscripts/xmppdaemon.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 3eecfec29..38d739e68 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -20,13 +20,14 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-$shortoptions = 'i::';
-$longoptions = array('id::');
+$shortoptions = 'fi::';
+$longoptions = array('id::', 'foreground');
$helptext = <<<END_OF_XMPP_HELP
Daemon script for receiving new notices from Jabber users.
-i --id Identity (default none)
+ -f --foreground Stay in the foreground (default background)
END_OF_XMPP_HELP;
@@ -42,8 +43,10 @@ require_once INSTALLDIR . '/lib/daemon.php';
class XMPPDaemon extends Daemon
{
- function XMPPDaemon($resource=null)
+ function XMPPDaemon($resource=null, $daemonize=true)
{
+ parent::__construct($daemonize);
+
static $attrs = array('server', 'port', 'user', 'password', 'host');
foreach ($attrs as $attr)
@@ -62,7 +65,6 @@ class XMPPDaemon extends Daemon
function connect()
{
-
$connect_to = ($this->host) ? $this->host : $this->server;
$this->log(LOG_INFO, "Connecting to $connect_to on port $this->port");
@@ -323,16 +325,16 @@ if (common_config('xmpp','enabled')==false) {
exit();
}
-if (have_option('i')) {
- $id = get_option_value('i');
-} else if (have_option('--id')) {
- $id = get_option_value('--id');
+if (have_option('i', 'id')) {
+ $id = get_option_value('i', 'id');
} else if (count($args) > 0) {
$id = $args[0];
} else {
$id = null;
}
-$daemon = new XMPPDaemon($id);
+$foreground = have_option('f', 'foreground');
+
+$daemon = new XMPPDaemon($id, $foreground);
$daemon->runOnce();