2 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 # Standalone HTTP server for public-inbox.
9 use PublicInbox::Daemon;
10 use PublicInbox::HTTP;
11 use PublicInbox::HTTPD;
18 eval { $app = Plack::Util::load_psgi(@ARGV) };
21 "$0 runs in /, command-line paths must be absolute\n";
24 require PublicInbox::WWW;
25 PublicInbox::WWW->preload;
26 my $www = PublicInbox::WWW->new;
38 "Plack::Middleware::Deflater missing, bandwidth will be wasted\n";
40 eval { enable 'ReverseProxy' };
42 "Plack::Middleware::ReverseProxy missing,\n",
43 "URL generation for redirects may be wrong if behind a reverse proxy\n";
46 sub { $www->call(@_) };
51 PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
52 sub ($$$) { # post_accept
53 my ($client, $addr, $srv) = @_;
54 my $fd = fileno($srv);
55 my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
56 PublicInbox::HTTP->new($client, $addr, $h),