-my $refresh = sub { $nntpd->refresh_groups };
-
-my %opts = (
- LocalAddr => '127.0.0.1:1133',
- Type => SOCK_STREAM,
- Proto => 'tcp',
- Blocking => 0,
- Reuse => 1,
- Listen => 1024,
-);
-my $s = IO::Socket::INET->new(%opts) or die "Error creating socket: $@\n";
-$s->sockopt(SO_KEEPALIVE, 1);
-$s->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1);
-
-$SIG{PIPE} = 'IGNORE';
-$SIG{HUP} = $refresh;
-$refresh->();
-
-Danga::Socket->AddOtherFds(fileno($s) => sub {
- while (my $c = $s->accept) {
- $c->blocking(0); # no accept4 :<
- PublicInbox::NNTP->new($c, $nntpd);
- }
-});
-Danga::Socket->EventLoop();
+daemon_run('0.0.0.0:119',
+ sub { $nntpd->refresh_groups }, # refresh
+ sub ($$$) { PublicInbox::NNTP->new($_[0], $nntpd) }); # post_accept