From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] daemon: document optional Net::Server dependency
Date: Sat, 5 Mar 2016 22:42:12 +0000 [thread overview]
Message-ID: <20160305224212.3600-1-e@80x24.org> (raw)
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
reply other threads:[~2016-03-05 22:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160305224212.3600-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.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.
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).