mojo icon indicating copy to clipboard operation
mojo copied to clipboard

Transform Morbo into a general purpose server restarter

Open kraih opened this issue 3 years ago • 1 comments

We already have support for receiving file descriptors from a parent process ($daemon->listen(['http://127.0.0.1?fd=3'])) in Mojo::Server::Daemon and Mojo::Server::Prefork for systemd. So Morbo feels a bit antiquated with its insistence on only supporting one specific web server.

Back when WSL did not yet exist it made sense to do it that way and have a somewhat working restarter on Windows, even if it only works half the time. But we can do better now, and there is no reason Morbo can't restart prefork web servers too. It would also help a lot with #1694.

$ morbo script/myapp daemon
...
$ morbo script/myapp prefork --workers 1
...
$ morbo --listen http://127.0.0.1:8080 --watch assets/css script/myapp prefork --workers 3
...

That's pretty much how i imagine it would work, the file descriptor could be passed along via environment variable. Otherwise just standard signals for process management and the same file watch behaviour for automatic restarts.

$ morbo script/myapp
...

Without extra arguments it could default to daemon for backwards compatibility. But it's not a hard requirement, since morbo is just a development tool.

kraih avatar Feb 22 '21 16:02 kraih

I think it's a good idea.

yuki-kimoto avatar Mar 08 '21 23:03 yuki-kimoto