about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-05-05 10:52:15 +0000
committerEric Wong <e@80x24.org>2022-05-05 10:52:35 +0000
commit93a7b219d58aad86438cbf3cbf4318a889831ac1 (patch)
tree892d17d602370be3b2c8bc6a36d46693682915bf /script
parent71eb48442e0f5403e9a5c3f0ccf8257600efe392 (diff)
downloadpublic-inbox-93a7b219d58aad86438cbf3cbf4318a889831ac1.tar.gz
Since we'll be adding POP3 support as our 4th network protocol;
asking admins to run yet another daemon on top of existing
-httpd, -nntpd, -imapd is a maintenance burden and a waste of
memory.

The goal of public-inbox-netd is to be able to replace all
existing read-only daemons with a single process to save memory
and reduce administrative overhead; hopefully encouraging more
users to self-host their own mirrors.

It's barely-tested at the moment.  Eventually, multiple
PI_CONFIG and HOME directories will be supported, as are
per-listener .psgi config files.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-httpd51
-rwxr-xr-xscript/public-inbox-imapd12
-rwxr-xr-xscript/public-inbox-netd6
-rwxr-xr-xscript/public-inbox-nntpd15
4 files changed, 17 insertions, 67 deletions
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
index a4dd8099..caceae20 100755
--- a/script/public-inbox-httpd
+++ b/script/public-inbox-httpd
@@ -1,51 +1,8 @@
-#!/usr/bin/perl -w
-# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
+#!perl -w
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Standalone HTTP server for public-inbox.
-use strict;
-use v5.10.1;
+use v5.12;
 use PublicInbox::Daemon;
-BEGIN {
-        for (qw(Plack::Builder Plack::Util)) {
-                eval("require $_") or die "E: Plack is required for $0\n";
-        }
-        Plack::Builder->import;
-        require PublicInbox::HTTP;
-        require PublicInbox::HTTPD;
-}
-
-my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_<NAME|PORT>}
-my $app;
-my $refresh = sub {
-        if (@ARGV) {
-                eval { $app = Plack::Util::load_psgi(@ARGV) };
-                if ($@) {
-                        die $@,
-"$0 runs in /, command-line paths must be absolute\n";
-                }
-        } else {
-                require PublicInbox::WWW;
-                my $www = PublicInbox::WWW->new;
-                $www->preload;
-                $app = builder {
-                        eval { enable 'ReverseProxy' };
-                        $@ and warn
-"Plack::Middleware::ReverseProxy missing,\n",
-"URL generation for redirects may be wrong if behind a reverse proxy\n";
-
-                        enable 'Head';
-                        sub { $www->call(@_) };
-                };
-        }
-        %httpds = (); # invalidate cache
-};
-
-PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
-        sub ($$$) { # Listener->{post_accept}
-                my ($client, $addr, $srv, $tls_wrap) = @_;
-                my $fd = fileno($srv);
-                my $h = $httpds{$fd} //=
-                        PublicInbox::HTTPD->new($srv, $app, $client);
-                PublicInbox::HTTP->new($client, $addr, $h),
-        });
+PublicInbox::Daemon::run('http://0.0.0.0:8080');
diff --git a/script/public-inbox-imapd b/script/public-inbox-imapd
index 6b755938..0c96cdbb 100755
--- a/script/public-inbox-imapd
+++ b/script/public-inbox-imapd
@@ -1,14 +1,8 @@
 #!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Standalone read-only IMAP server for public-inbox.
-use strict;
+use v5.12;
 use PublicInbox::Daemon;
-use PublicInbox::IMAPdeflate; # loads PublicInbox::IMAP
-use PublicInbox::IMAPD;
-my $imapd = PublicInbox::IMAPD->new;
-PublicInbox::Daemon::run('0.0.0.0:143',
-        sub { $imapd->refresh_groups(@_) }, # refresh
-        sub ($$$) { PublicInbox::IMAP->new($_[0], $imapd) }, # post_accept
-        $imapd);
+PublicInbox::Daemon::run('imap://0.0.0.0:143');
diff --git a/script/public-inbox-netd b/script/public-inbox-netd
new file mode 100755
index 00000000..e8b1ca69
--- /dev/null
+++ b/script/public-inbox-netd
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -w
+# Copyright (C) all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use v5.12;
+use PublicInbox::Daemon;
+PublicInbox::Daemon::run();
diff --git a/script/public-inbox-nntpd b/script/public-inbox-nntpd
index 9fb0a8d9..aca27383 100755
--- a/script/public-inbox-nntpd
+++ b/script/public-inbox-nntpd
@@ -1,15 +1,8 @@
-#!/usr/bin/perl -w
-# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
+#!perl -w
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Standalone NNTP server for public-inbox.
-use strict;
-use warnings;
+use v5.12;
 use PublicInbox::Daemon;
-use PublicInbox::NNTPdeflate; # loads PublicInbox::NNTP
-use PublicInbox::NNTPD;
-my $nntpd = PublicInbox::NNTPD->new;
-PublicInbox::Daemon::run('0.0.0.0:119',
-        sub { $nntpd->refresh_groups }, # refresh
-        sub ($$$) { PublicInbox::NNTP->new($_[0], $nntpd) }, # post_accept
-        $nntpd);
+PublicInbox::Daemon::run('nntp://0.0.0.0:119');