-
-
Save anonymous/7db38f2441d6cd59962134c738b9dcda 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
# Stop prefork workers gracefully once they reach a certain size | |
my $parent = $$; | |
Mojo::IOLoop->next_tick( | |
sub { | |
Mojo::IOLoop->recurring( | |
5 => sub { | |
my $rss = (getrusage())[2]; | |
my $max = $config->{max_worker_rss}; | |
return unless $rss > $max; | |
$app->log->warn( | |
qq{Worker exceeded RSS limit "$rss > $max", restarting}); | |
Mojo::IOLoop->stop_gracefully; | |
} | |
) if $parent ne $$; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment