jamesmcm / vopono

Run applications through VPN tunnels with temporary network namespaces
GNU General Public License v3.0
790 stars 44 forks source link

Call systemd's `sd_notify` when doing `--create-netns-only` #255

Open musjj opened 3 months ago

musjj commented 3 months ago

I'm running vopono as a root service, which works pretty well (despite this issue: https://github.com/jamesmcm/vopono/issues/84?). But it would be nicer if the service can be notified when the namespace is actually created, to avoid race conditions.

Daemons can do this by calling sd_notify. Services with Type=notify will then respond accordingly:

https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Type=

Behavior of notify is similar to exec; however, it is expected that the service sends a "READY=1" notification message via sd_notify(3) or an equivalent call when it has finished starting up. systemd will proceed with starting follow-up units after this notification message has been sent.

jamesmcm commented 3 months ago

You might be able to do this already with a --postup script btw, but I'll take a look and try it out, thanks!

musjj commented 3 months ago

Thanks, passing a systemd-notify --ready script to --postup works pretty well for me!