zerotier/ZeroTierOne

zerotier-one should support systemd notification

Open

#2,277 opened on Apr 27, 2024

View on GitHub
 (3 comments) (1 reaction) (0 assignees)C++ (1,558 forks)batch import
Good First IssueLinuxType: Enhancement

Repository metrics

Stars
 (12,761 stars)
PR merge metrics
 (Avg merge 265d 19h) (1 merged PR in 30d)

Description

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.

Contributor guide