]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: avoid polluting the main package
authorEric Wong <e@80x24.org>
Thu, 3 Mar 2016 05:14:30 +0000 (05:14 +0000)
committerEric Wong <e@80x24.org>
Thu, 3 Mar 2016 09:19:05 +0000 (09:19 +0000)
We've distilled the daemon code into one public function ("run"),
so avoid polluting the main namespace and just have users
prefix with the full package name for this rarely-used class.

lib/PublicInbox/Daemon.pm
script/public-inbox-httpd
script/public-inbox-nntpd

index 45c1563478a3c9adfa3ccd33de566d2bb0605c0b..77ab2a71c166ba39b7844c8186baeec3bf1530ab 100644 (file)
@@ -1,10 +1,8 @@
 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
-package PublicInbox::Daemon; # empty class :p
-
 # contains common daemon code for the nntpd and httpd servers.
 # This may be used for read-only IMAP server if we decide to implement it.
-package main;
+package PublicInbox::Daemon;
 use strict;
 use warnings;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
@@ -383,7 +381,7 @@ sub daemon_loop ($$) {
 }
 
 
-sub daemon_run ($$$) {
+sub run ($$$) {
        my ($default, $refresh, $post_accept) = @_;
        daemon_prepare($default);
        daemonize();
index 215796225d8043c95e7e8ce219289c45cc86d762..d867b47718e764454b6472c7dcd8311b9ccae37d 100755 (executable)
@@ -49,7 +49,7 @@ my $refresh = sub {
        }
 };
 
-daemon_run('0.0.0.0:8080', $refresh,
+PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
        sub ($$$) { # post_accept
                my ($client, $addr, $srv) = @_;
                my $fd = fileno($srv);
index 23d269d4b778c9ffb6480f81ef3154eac56a72b3..cea881632ca5e6318d471df78e212ff1bc83d6df 100755 (executable)
@@ -10,7 +10,7 @@ require PublicInbox::NewsGroup;
 require PublicInbox::NNTP;
 require PublicInbox::Config;
 my $nntpd = PublicInbox::NNTPD->new;
-daemon_run('0.0.0.0:119',
+PublicInbox::Daemon::run('0.0.0.0:119',
        sub { $nntpd->refresh_groups }, # refresh
        sub ($$$) { PublicInbox::NNTP->new($_[0], $nntpd) }); # post_accept