about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-03-05 22:42:12 +0000
committerEric Wong <e@80x24.org>2016-03-05 22:42:35 +0000
commitbc5f141e8e4e4df3813dd123cf5a76355e65be17 (patch)
tree581779bc121993bab0cf16b0b931e8fe45f0e9f1
parentd3ded72481e6435fc67f2d1cb9ae9cf7ffe8d753 (diff)
downloadpublic-inbox-bc5f141e8e4e4df3813dd123cf5a76355e65be17.tar.gz
Non-socket activation users will want to install Net::Server
for daemonization, pid file writing, and user/group switching.
-rw-r--r--INSTALL5
-rw-r--r--lib/PublicInbox/Daemon.pm6
-rw-r--r--t/httpd-unix.t6
3 files changed, 13 insertions, 4 deletions
diff --git a/INSTALL b/INSTALL
index 54c344c7..013e8d15 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 8a0af8de..51562624 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 580d14d2..b3368491 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;