unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] daemon: do not chdir unless daemonizing
@ 2016-08-02  7:49 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-08-02  7:49 UTC (permalink / raw)
  To: meta

As far as most process managers are concerned (e.g. systemd),
they should already start in '/'.  So avoid making our daemon
more complex to run by requiring absolute paths during
development.
---
 lib/PublicInbox/Daemon.pm | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 9125584..795ab82 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -102,16 +102,18 @@ sub check_absolute ($$) {
 }
 
 sub daemonize () {
-	foreach my $i (0..$#ARGV) {
-		my $arg = $ARGV[$i];
-		next unless -e $arg;
-		$ARGV[$i] = abs_path($arg);
-	}
-	check_absolute('stdout', $stdout);
-	check_absolute('stderr', $stderr);
-	check_absolute('pid-file', $pid_file);
+	if ($daemonize) {
+		foreach my $i (0..$#ARGV) {
+			my $arg = $ARGV[$i];
+			next unless -e $arg;
+			$ARGV[$i] = abs_path($arg);
+		}
+		check_absolute('stdout', $stdout);
+		check_absolute('stderr', $stderr);
+		check_absolute('pid-file', $pid_file);
 
-	chdir '/' or die "chdir failed: $!";
+		chdir '/' or die "chdir failed: $!";
+	}
 
 	return unless (defined $pid_file || defined $group || defined $user
 			|| $daemonize);
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-02  7:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02  7:49 [PATCH] daemon: do not chdir unless daemonizing Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).