summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-10 11:54:00 -0800
committerBrion Vibber <brion@pobox.com>2010-03-10 11:54:00 -0800
commit532e486a936c78961ff93d5e8de2dc0b86ee8d2a (patch)
treece7dce785643e76df6f9a65d96b1c2ffb95ecf57 /scripts
parent55e8473a7a87ebe85bcfa5cfb409ce9a9aeafdd0 (diff)
Detect when queuedaemon/xmppdaemon parent processes die and kill the child processes.
Keeps stray daemon subprocesses from floating around when we kill the parents via a signal! Accomplished by opening a bidirectional pipe in the parent process; the children close out the writer end and keep the reader in their open sockets list. When the parent dies, the children see that the socket's been closed out and can perform an orderly shutdown.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/queuedaemon.php11
-rwxr-xr-xscripts/xmppdaemon.php11
2 files changed, 20 insertions, 2 deletions
diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php
index 6dba16f95..582a3dd88 100755
--- a/scripts/queuedaemon.php
+++ b/scripts/queuedaemon.php
@@ -105,7 +105,7 @@ class QueueDaemon extends SpawningDaemon
{
$this->log(LOG_INFO, 'checking for queued notices');
- $master = new QueueMaster($this->get_id());
+ $master = new QueueMaster($this->get_id(), $this->processManager());
$master->init($this->allsites);
try {
$master->service();
@@ -125,6 +125,14 @@ class QueueDaemon extends SpawningDaemon
class QueueMaster extends IoMaster
{
+ protected $processManager;
+
+ function __construct($id, $processManager)
+ {
+ parent::__construct($id);
+ $this->processManager = $processManager;
+ }
+
/**
* Initialize IoManagers which are appropriate to this instance.
*/
@@ -135,6 +143,7 @@ class QueueMaster extends IoMaster
$qm = QueueManager::get();
$qm->setActiveGroup('main');
$managers[] = $qm;
+ $managers[] = $this->processManager;
}
Event::handle('EndQueueDaemonIoManagers', array(&$managers));
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 9302f0c43..26c7991b8 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -55,7 +55,7 @@ class XMPPDaemon extends SpawningDaemon
{
common_log(LOG_INFO, 'Waiting to listen to XMPP and queues');
- $master = new XmppMaster($this->get_id());
+ $master = new XmppMaster($this->get_id(), $this->processManager());
$master->init($this->allsites);
$master->service();
@@ -68,6 +68,14 @@ class XMPPDaemon extends SpawningDaemon
class XmppMaster 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.
@@ -79,6 +87,7 @@ class XmppMaster extends IoMaster
$qm->setActiveGroup('xmpp');
$this->instantiate($qm);
$this->instantiate(XmppManager::get());
+ $this->instantiate($this->processManager);
}
}
}