dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 1/2] daemon: do not chdir unless daemonizing
Date: Tue,  2 Aug 2016 01:47:54 +0000	[thread overview]
Message-ID: <20160802014755.24520-1-e@80x24.org> (raw)

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


             reply	other threads:[~2016-08-02  1:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02  1:47 Eric Wong [this message]
2016-08-02  1:47 ` [PATCH 2/2] wwwstream: prioritize search in top title bar Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160802014755.24520-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).