about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-08-02 01:47:54 +0000
committerEric Wong <e@80x24.org>2016-08-02 07:49:22 +0000
commit21d3fe9db86dc235b914cedbb21b513b96b95184 (patch)
tree8bb9c97b93d15fd9ae25345422b97bf88ef57505 /lib
parent3f4c9ce3d2c0796c6c3f352b5b586ddd7a85ffb0 (diff)
downloadpublic-inbox-21d3fe9db86dc235b914cedbb21b513b96b95184.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Daemon.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 9125584b..795ab822 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);