=head1 SYNOPSIS
public-inbox-httpd
+ public-inbox-imapd
public-inbox-nntpd
=head1 DESCRIPTION
This manual describes common options and behavior for
public-inbox network daemons. Network daemons for public-inbox
-provide read-only NNTP and HTTP access to public-inboxes. Write
+provide read-only NNTP, IMAP and HTTP access to public-inboxes. Write
access to a public-inbox will never be required to run these.
These daemons are implemented with a common core using
=item SIGHUP
Reload config files associated with the process.
-(FIXME: not tested for -httpd, yet)
+(Note: broken for L<public-inbox-httpd(1)> only in E<lt>= 1.6)
=item SIGTTIN
=head1 SEE ALSO
-L<public-inbox-httpd(1)>, L<public-inbox-nntpd(1)>
+L<public-inbox-httpd(1)>, L<public-inbox-imapd(1)>,
+L<public-inbox-nntpd(1)>
#
# Standalone HTTP server for public-inbox.
use strict;
+use v5.10.1;
use PublicInbox::Daemon;
BEGIN {
for (qw(Plack::Builder Plack::Util)) {
require PublicInbox::HTTPD;
}
-my %httpds;
+my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_<NAME|PORT>}
my $app;
my $refresh = sub {
if (@ARGV) {
sub { $www->call(@_) };
};
}
+ %httpds = (); # invalidate cache
};
PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
sub ($$$) { # post_accept
my ($client, $addr, $srv) = @_;
my $fd = fileno($srv);
- my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
+ my $h = $httpds{$fd} //= PublicInbox::HTTPD->new($srv, $app);
PublicInbox::HTTP->new($client, $addr, $h),
});
nntp
EOF
};
+ my $i2 = create_inbox 'test-2', sub {
+ my ($im, $ibx) = @_;
+ $im->add(eml_load('t/plack-qp.eml')) or xbail '->add';
+ };
local $ENV{HOME} = $home;
my $cmd = [ '-init', $group, $inboxdir, 'http://example.com/', $addr ];
ok(run_script($cmd), 'init ran properly');
"$http_pfx/$group", "$tmpdir/dumb.git"),
0, 'clone successful');
+ # test config reload
+ my $cfg = "$home/.public-inbox/config";
+ open my $fh, '>>', $cfg or xbail "open: $!";
+ print $fh <<EOM or xbail "print $!";
+[publicinbox "test-2"]
+ inboxdir = $i2->{inboxdir}
+ address = test-2\@example.com
+ url = https://example.com/test-2
+EOM
+ close $fh or xbail "close $!";
+ $td->kill('HUP') or BAIL_OUT "failed to kill -httpd: $!";
+ tick; # wait for HUP to take effect
+ my $buf = do {
+ my $c2 = tcp_connect($sock);
+ $c2->write("GET /test-2/qp\@example.com/raw HTTP/1.0\r\n\r\n")
+ or xbail "c2 write: $!";
+ local $/;
+ <$c2>
+ };
+ like($buf, qr!\AHTTP/1\.0 200\b!s, 'got 200 after reload for test-2');
+
ok($td->kill, 'killed httpd');
$td->join;