Graceful system restarts
• Mark Eschbach
I have a setup of service which is launched and maintained by SystemD. The service has a dependency on etcd
being up and running in the After
section of the SystemD script as follows:
[Unit]
Description=Web User Interface - %i
After=etcd2.service nginx-dynamic-proxy.service
[Service]
SyslogIdentifier=some-service
User=some-service
Group=some-service
Nice=10
PIDFile=/opt/some-service/pids/some-service.%i.pid
ExecStart=/opt/some-service/bin/wui %i
ExecReload=/bin/kill -s USR2 $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
Unforunately I’ve found when this machine is restarted the some-service
application is started before etcd
is actually available for to service requests. I’m guessing it’s actually a problem with my hand written etcd
service file. Looking at official etcd examples didn’t yeild much. Doesn’t look like etcd2 has many details either. sd_notify
protocol isn’t an option, so that leaves an HTTP check.
Does SystemD have an HTTP health check? Doesn’t look like it :-(. The post illudes to a mechnism which would only test if the socket is available but that is a great first step in my opinion.
After reading 0pointer’s article on the watchdog I’m not entirely sure. After checking on NotifyAccess
from the manual now I’m really questioning if this is possible. Perhaps I’m approaching the problem entirely incorrectly and should be looking at it through the view of a systemd.socket
. Hmm, I’ll have to return to this project some other time.