-
-
Save anonymous/16516f34dd826216cbc575074011dd69 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
use BSD::Resource; | |
use Mojo::IOLoop; | |
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; | |
$self->log->debug( | |
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