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: document optional Net::Server dependency
@ 2016-03-05 22:42  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-03-05 22:42 UTC (permalink / raw)
  To: meta

Non-socket activation users will want to install Net::Server
for daemonization, pid file writing, and user/group switching.
---
 INSTALL                   | 5 +++--
 lib/PublicInbox/Daemon.pm | 6 +++++-
 t/httpd-unix.t            | 6 +++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/INSTALL b/INSTALL
index 54c344c..013e8d1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -47,10 +47,11 @@ Optional modules:
   - DBI[3]                     libdbi-perl
   - DBD::SQLite[3]             libdbd-sqlite3-perl
   - Danga::Socket[4]           libdanga-socket-perl
+  - Net::Server[4]             libnet-server-perl
 
 [1] - Only required for serving/generating Atom and HTML pages.
-[3] - Optional for HTML web interface and NNTP server
-[4] - Optional for NNTP server
+[3] - Optional for HTML web interface and HTTP/NNTP servers
+[4] - Optional for HTTP and NNTP servers
 
 Copyright
 ---------
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 8a0af8d..5156262 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -94,7 +94,11 @@ sub daemonize () {
 	return unless (defined $pid_file || defined $group || defined $user
 			|| $daemonize);
 
-	require Net::Server::Daemonize;
+	eval { require Net::Server::Daemonize };
+	if ($@) {
+		die
+"Net::Server required for --pid-file, --group, --user, and --daemonize\n$@\n";
+	}
 
 	Net::Server::Daemonize::check_pid_file($pid_file) if defined $pid_file;
 	$uid = Net::Server::Daemonize::get_uid($user) if defined $user;
diff --git a/t/httpd-unix.t b/t/httpd-unix.t
index 580d14d..b336849 100644
--- a/t/httpd-unix.t
+++ b/t/httpd-unix.t
@@ -81,7 +81,11 @@ check_sock($unix);
 	is($?, 0, 'existing httpd exited successfully');
 	ok(-S $unix, 'unix socket still exists');
 }
-{
+
+SKIP: {
+	eval 'require Net::Server::Daemonize';
+	skip('Net::Server missing for pid-file/daemonization test', 10) if $@;
+
 	# wait for daemonization
 	$spawn_httpd->("-l$unix", '-D', '-P', "$tmpdir/pid");
 	my $kpid = $pid;
-- 
EW


^ permalink raw reply	[relevance 7%]

Results 1-1 of 1 | reverse | sort options + mbox downloads above
-- links below jump to the message on this page --
2016-03-05 22:42  7% [PATCH] daemon: document optional Net::Server dependency Eric Wong

Code repositories for project(s) associated with this 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).