STDOUT->autoflush(1);
STDERR->autoflush(1);
use PublicInbox::DS qw(now);
-use PublicInbox::Syscall qw(SFD_NONBLOCK);
+use PublicInbox::Syscall qw($SFD_NONBLOCK);
require PublicInbox::Listener;
-require PublicInbox::ParentPipe;
+use PublicInbox::EOFpipe;
use PublicInbox::Sigfd;
my @CMD;
my ($set_user, $oldset);
my $listener_names = {}; # sockname => IO::Handle
my $oldset = PublicInbox::Sigfd::block_signals();
@CMD = ($0, @ARGV);
- my %opts = (
+ my ($prog) = ($CMD[0] =~ m!([^/]+)\z!g);
+ my $help = <<EOF;
+usage: $prog [-l ADDRESS] [--cert=FILE] [--key=FILE]
+
+options:
+
+ -l ADDRESS address to listen on (default: $default_listen)
+ --cert=FILE default SSL/TLS certificate
+ --key=FILE default SSL/TLS certificate
+ -W WORKERS number of worker processes to spawn (default: 1)
+
+See public-inbox-daemon(8) and $prog(1) man pages for more.
+EOF
+ my %opt = (
'l|listen=s' => \@cfg_listen,
'1|stdout=s' => \$stdout,
'2|stderr=s' => \$stderr,
'D|daemonize' => \$daemonize,
'cert=s' => \$default_cert,
'key=s' => \$default_key,
+ 'help|h' => \(my $show_help),
);
- GetOptions(%opts) or die "bad command-line args\n";
+ GetOptions(%opt) or die $help;
+ if ($show_help) { print $help; exit 0 };
if (defined $pid_file && $pid_file =~ /\.oldbin\z/) {
die "--pid-file cannot end with '.oldbin'\n";
sub master_loop {
pipe(my ($p0, $p1)) or die "failed to create parent-pipe: $!";
- # 1031: F_SETPIPE_SZ, 4096: page size
- fcntl($p1, 1031, 4096) if $^O eq 'linux';
my $set_workers = $worker_processes;
reopen_logs();
my $ignore_winch;
if ($worker_processes > 0) {
$refresh->(); # preload by default
my $fh = master_loop(); # returns if in child process
- PublicInbox::ParentPipe->new($fh, \&worker_quit);
+ PublicInbox::EOFpipe->new($fh, \&worker_quit, undef);
} else {
reopen_logs();
$set_user->() if $set_user;
# this calls epoll_create:
PublicInbox::Listener->new($_, $tls_cb || $post_accept)
} @listeners;
- my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
+ my $sigfd = PublicInbox::Sigfd->new($sig, $SFD_NONBLOCK);
local %SIG = (%SIG, %$sig) if !$sigfd;
if (!$sigfd) {
# wake up every second to accept signals if we don't