user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] daemon: expand @ARGV paths for running in '/'
@ 2016-03-17  1:59  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-03-17  1:59 UTC (permalink / raw)
  To: meta

We also require --stdout/--stderr/--pid-file to be absolute
paths for USR2 usage.  However, allow PSGI files for -httpd
to be relative paths for ease-of-use.
---
 lib/PublicInbox/Daemon.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index c6fb62b..c9594a3 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -8,6 +8,7 @@ use warnings;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use IO::Handle;
 use IO::Socket;
+use Cwd qw/abs_path/;
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
 require Danga::Socket;
@@ -91,7 +92,24 @@ sub daemon_prepare ($) {
 	die "No listeners bound\n" unless @listeners;
 }
 
+sub check_absolute ($$) {
+	my ($var, $val) = @_;
+	if (defined $val && index($val, '/') != 0) {
+		die
+"--$var must be an absolute path when using --daemonize: $val\n";
+	}
+}
+
 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);
+
 	chdir '/' or die "chdir failed: $!";
 	open(STDIN, '+<', '/dev/null') or die "redirect stdin failed: $!";
 
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-03-17  1:59  7% [PATCH] daemon: expand @ARGV paths for running in '/' Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).