倉庫指標
- Star
- (12,761 star)
- PR 合併指標
- (平均合併 265天 19小時) (30 天內合併 1 個 PR)
描述
Here's the problem:
$ sudo systemctl start zerotier-one && sudo zerotier-cli info
Error connecting to the ZeroTier service: connection failed
Please check that the service is running and that TCP port 9993 can be contacted via 127.0.0.1.
systemctl start will wait until a service is ready before returning - which is essential to avoid race conditions when installing and configuring zerotier from a script. However this only works for Type=notify services. Otherwise a small sleep is required, which is needlessly pessimistic when the zerotier-one service is already running.
ZeroTier One should support systemd notification so that it can notify systemd when it has bound to its control interface and is ready to accept commands.
Implementing notification is simple: if the NOTIFY_SOCKET env var is set, open a datagram socket and write READY=1 once the service has finished booting.
I've had a quick look at the code, and I think here would be the right place to insert the ready notification.