]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: refresh before forking
authorEric Wong <e@80x24.org>
Sat, 27 Feb 2016 22:36:32 +0000 (22:36 +0000)
committerEric Wong <e@80x24.org>
Sat, 27 Feb 2016 22:41:32 +0000 (22:41 +0000)
This means we always load the PSGI server code early for
-httpd.  This may make things less compatible with existing
PSGI/Plack apps, but we prioritize our httpd for the uses
of public-inbox itself, first.

And any existing PSGI/Plack app which wants to may adapt
themselves to being preload-friendly.

lib/PublicInbox/Daemon.pm

index 2878e33b7a155aff13ed0bffdc0c832d7b464c38..b8482d36c6de884c200872417d22f96459730994 100644 (file)
@@ -363,6 +363,7 @@ sub daemon_loop ($$) {
        my ($refresh, $post_accept) = @_;
        my $parent_pipe;
        if ($worker_processes > 0) {
+               $refresh->(); # preload by default
                $parent_pipe = master_loop(); # returns if in child process
                my $fd = fileno($parent_pipe);
                Danga::Socket->AddOtherFds($fd => sub { kill('TERM', $$) } );
@@ -370,10 +371,10 @@ sub daemon_loop ($$) {
                reopen_logs();
                $set_user->() if $set_user;
                $SIG{USR2} = sub { worker_quit() if upgrade() };
+               $refresh->();
        }
        $uid = $gid = undef;
        reopen_logs();
-       $refresh->();
        $SIG{QUIT} = $SIG{INT} = $SIG{TERM} = *worker_quit;
        $SIG{USR1} = *reopen_logs;
        $SIG{HUP} = $refresh;