mojolicious/mojo

Helper process support for Mojo::Server::Daemon/Prefork

开放

#1,694 创建于 2021年2月7日

 (2 条评论) (0 个反应) (0 位负责人)Perl (591 个派生)auto 404
feature requesthelp wanted

仓库指标

星标
 (2,745 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南