Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kraih opened this issue Feb 7, 2021 · 2 comments
Open

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

kraih opened this issue Feb 7, 2021 · 2 comments

Comments

@kraih
Copy link
Member

kraih commented Feb 7, 2021

The motivation for this is mojolicious/minion#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.

@kraih
Copy link
Member Author

kraih commented Feb 7, 2021

There will probably have to be two completely separate code paths in the plugin for daemon and prefork. Since both are so different. That is fine.

@kraih
Copy link
Member Author

kraih commented Feb 22, 2021

I've been thinking a bit more about this feature, and actually most real deployments are just prefork these days. And prefork already has process management features (for the workers) we could expand to include helper processes. The only real blocker here is morbo, which needs the feature for development and uses daemon. Perhaps we could switch morbo to prefork and sidestep the problem that way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant