From 6ca4dfa7ef42faf024599375b2ff81bfeb3d6208 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 16:12:23 -0400 Subject: Daemon can optionally not go into the background --- lib/daemon.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib/daemon.php') diff --git a/lib/daemon.php b/lib/daemon.php index a0df00bdc..72e8bc202 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -23,6 +23,13 @@ if (!defined('LACONICA')) { class Daemon { + var $daemonize = true; + + function __construct($daemonize = true) + { + $this->daemonize = $daemonize; + } + function name() { return null; @@ -129,12 +136,15 @@ class Daemon common_log(LOG_INFO, $this->name() . ' already running. Exiting.'); exit(0); } - if ($this->background()) { - $this->writePidFile(); - $this->changeUser(); - $this->run(); - $this->clearPidFile(); + + if ($this->daemonize) { + $this->background(); } + + $this->writePidFile(); + $this->changeUser(); + $this->run(); + $this->clearPidFile(); } function run() -- cgit v1.2.3-54-g00ecf From 5cc58f1e01c38fbf33f3d663231b7a66cdf3310e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:38:02 -0400 Subject: note when going background --- lib/daemon.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/daemon.php') diff --git a/lib/daemon.php b/lib/daemon.php index 72e8bc202..90dd773c6 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -138,6 +138,7 @@ class Daemon } if ($this->daemonize) { + common_log('Backgrounding daemon "'.$this->name().'"'); $this->background(); } -- cgit v1.2.3-54-g00ecf From 6557a569e595eee75609eb6cf12e6e788061daa9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 28 Jun 2009 17:41:16 -0400 Subject: fix logging error --- lib/daemon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/daemon.php') diff --git a/lib/daemon.php b/lib/daemon.php index 90dd773c6..9d89c63e7 100644 --- a/lib/daemon.php +++ b/lib/daemon.php @@ -138,7 +138,7 @@ class Daemon } if ($this->daemonize) { - common_log('Backgrounding daemon "'.$this->name().'"'); + common_log(LOG_INFO, 'Backgrounding daemon "'.$this->name().'"'); $this->background(); } -- cgit v1.2.3-54-g00ecf