Closed jchayan closed 3 years ago
Yes. PR Is welcome
I'm planning to take a swing at this tomorrow. I will reply with a PR if I get around to it!
@chriscz Thanks a lot, I haven't had the time to take a look at this but the only thing I can tell you is to watch out for the ExecStop
and ExecReload
values on the unit file generated by this gem: https://github.com/seuros/capistrano-puma/blob/212d03a3cdf1f22b15a183fe92fafa3d7284ac4c/lib/capistrano/templates/puma.service.erb#L9-L11
At least in my case, they don't seem to actually stop or restart the Puma process and that renders the socket activation mechanism useless and in any case I think it's a bad practice to try to send a signal to $MAINPID using /bin/kill
, systemd already does this for you.
For what I see in the documentation we only need to specify ExecStart
and systemd will handle the rest: https://github.com/puma/puma/blob/master/docs/systemd.md
Removing ExecStop and ExecReload did the trick for me and now I have 2 services effectively running with socket activation. @chriscz Let me know if I can be of help
Apparently the ExecStop command was already removed in 5a280fee5a966eb3e2f9d089c702d5fc5f96aa6e PR: https://github.com/seuros/capistrano-puma/pull/314
@jchayan Thanks for the information. I'm sure this is going to help a lot. I mostly use Ansible to set things up so I'll probably re-use the templates there whem I'm done.
I find the use of ExecReload
sending the STOP
signal a bit odd because its undocumented in Puma: https://github.com/puma/puma/blob/master/docs/signals.md and from my experience the process just stops executing but isn't killed. Could you explain by any chance @seuros ?
Phased restarts don't seem to be necessary when you have socket activation but they do offer a better user experience afaik because request latency is reduced, but from the looks of it this was never supported in the service file.
Also just realised that multiple binds are possible so may need to generate a socket file for each!
Stale issue message
Socket activation is a mechanism in Systemd that allows processes to achieve graceful restarts.
As documented here: https://github.com/puma/puma/blob/master/docs/systemd.md#socket-activation
I'm creating this issue to see if we can add a configuration to enable socket activation in the configuration