I have an HTTP service (let's call it Foo) with systemd socket activation. I would like to support this setup:
- monitoring service tells Foo to stop (e.g. POST /stop)
- Foo finishes it's (potentially long) work then exits.
- monitoring service polls an HTTP endpoint on Foo (e.g. GET /are-you-up) waiting for it to exit.
At step 3 when the monitoring service hits /are-you-up, systemd's socket activation restarts the HTTP service!
I'd still like systemd to manage the socket (so that my service doesn't have to run/start as root). I'd also still like systemd to restart my service if it crashes (non-0 exit code).
Are either of these possible?
- systemd manages the socket but doesn't do socket activation?
- OR Foo service on shutdown tells systemd to close the socket / stop responding to it. I tried having the service run 'systemctl stop foo.socket' but it runs as an unprivileged user.
The big picture is that the service is being replaced. After it shuts down the (cloud) server will be deleted.