scripts daemonize themselves

darcs-hash:20080904184031-84dde-eba2061f3aa898d0c791ffeb70837f759778c567.gz
This commit is contained in:
Evan Prodromou
2008-09-04 14:40:31 -04:00
parent 95d9920d78
commit aed0fff4ea
9 changed files with 167 additions and 37 deletions

View File

@@ -63,7 +63,10 @@ class XmppConfirmHandler {
$this->conn->presence(NULL, 'available', NULL, 'available', -1);
}
function handle_queue() {
function run() {
if (!$this->start()) {
return false;
}
$this->log(LOG_INFO, 'checking for queued confirmations');
do {
$confirm = $this->next_confirm();
@@ -99,6 +102,10 @@ class XmppConfirmHandler {
$this->idle(10);
}
} while (true);
if (!$this->finish()) {
return false;
}
return true;
}
function next_confirm() {
@@ -181,8 +188,5 @@ $resource = ($argc > 1) ? $argv[1] : (common_config('xmpp', 'resource').'-confir
$handler = new XmppConfirmHandler($resource);
if ($handler->start()) {
$handler->handle_queue();
}
$handler->runOnce();
$handler->finish();