Helper process support for Mojo::Server::Daemon/Prefork
#1,694 opened on Feb 7, 2021
Repository metrics
- Stars
- (2,745 stars)
- PR merge metrics
- (PR metrics pending)
Description
The motivation for this is https://github.com/mojolicious/minion/issues/76. But there are many other use cases for running arbitrary code in a persistent helper process next to the Mojolicious application server.
While forking such a process from a before_server_start hook is fairly trivial, making it work with Mojo::Server::Daemon as well as Mojo::Server::Prefork is not. Especially stopping the process together with the main application server process is tricky. It will have to work with Mojo::Server::Morbo and Mojo::Server::Hypnotoad too. There also needs to be some way to handle failures in the helper process (at the very least logging the exit code/signal as an error). And multiple helper processes should not interfere with each other of course.
API wise, we don't need anything fancy, a simple plugin should do just fine for now.
plugin HelperProcess => {run => sub ($app) {
while (1) {
sleep 1;
$app->log->debug("Helper process $$ is still running");
}
}};
Process management is the main priority and needs to be rock solid. With very good test coverage.