-
-
Save anonymous/234d8c714885e6d7b77a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Log.pm b/lib/Mojo/Log.pm | |
index 63d50d5..846b9bd 100644 | |
--- a/lib/Mojo/Log.pm | |
+++ b/lib/Mojo/Log.pm | |
@@ -56,6 +56,8 @@ sub new { | |
return $self; | |
} | |
+sub reopen { delete shift->{handle} } | |
+ | |
sub warn { shift->log(warn => @_) } | |
sub _format { | |
diff --git a/lib/Mojo/Server/Prefork.pm b/lib/Mojo/Server/Prefork.pm | |
index d3f39a6..73b34e3 100644 | |
--- a/lib/Mojo/Server/Prefork.pm | |
+++ b/lib/Mojo/Server/Prefork.pm | |
@@ -93,6 +93,10 @@ sub run { | |
($w->{graceful} = steady_time) and last unless $w->{graceful}; | |
} | |
}; | |
+ local $SIG{USR1} = sub { | |
+ $self->app->log->reopen; | |
+ kill 'USR1', $_ for keys %{$self->{pool}}; | |
+ }; | |
# Preload application before starting workers | |
$self->start->app->log->info("Manager $$ started"); | |
@@ -191,6 +195,7 @@ sub _spawn { | |
# Clean worker environment | |
$SIG{$_} = 'DEFAULT' for qw(CHLD INT TERM TTIN TTOU); | |
$SIG{QUIT} = sub { $loop->max_connections(0) }; | |
+ $SIG{USR1} = sub { $self->app->log->reopen }; | |
delete @$self{qw(poll reader)}; | |
srand; | |
diff --git a/lib/Mojolicious/Plugin/Mount.pm b/lib/Mojolicious/Plugin/Mount.pm | |
index 5a78acd..1d4ef6a 100644 | |
--- a/lib/Mojolicious/Plugin/Mount.pm | |
+++ b/lib/Mojolicious/Plugin/Mount.pm | |
@@ -7,7 +7,7 @@ sub register { | |
my ($self, $app, $conf) = @_; | |
my $path = (keys %$conf)[0]; | |
- my $embed = Mojo::Server->new->load_app($conf->{$path}); | |
+ my $embed = Mojo::Server->new->load_app($conf->{$path})->log($app->log); | |
# Extract host | |
my $host; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment