Dynamically restart a service via dbus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Dynamically restart a service via dbus
- From: "Matwey V. Kornilov" <matwey.kornilov@xxxxxxxxx>
- Date: Sat, 1 Feb 2025 14:38:20 +0300
- User-agent: Mozilla Thunderbird
Hi,
Let me please describe my initial problem and then explain what did I
try and what is my issue.
I have a systemd service with Restart=always and pretty large
RestartSec, say 10 minutes. The service executable communicates with a
remote host, when the host becomes unavailable the service exits. If
systemd tries to restart the service when the host is unavailable then
the service exits shortly after the process is spawned. The current
configuration performs unattended service recovery in face of the host
unavailability.
I want to improve this configuration. It appeared that I can track an
event when the host is up again. More precisely, I use dbus events of
dnsmasq DHCP server. Initially, I decided just to call RestartUnit() at
org.freedesktop.systemd1.Manager dbus interface. But I quickly realized
that this solution doesn't respect whether the service is enabled or
disabled by administrator. I could get the service enabled/disabled
state via dbus before, but it will not be atomic. There is also race
condition when the service is being restarted and I issue RestartUnit()
call, but it seems to be handled by mode parameter.
My question is whether there is better solution for my initial problem
or is there a way to atomically handle units via dbus systemd interface?
[Index of Archives]
[LARTC]
[Bugtraq]
[Yosemite Forum]
[Photo]