[systemd-devel] Service reactivation with device plugging
Kok, Auke-jan H
auke-jan.h.kok at intel.com
Tue Jul 3 16:30:31 PDT 2012
On Tue, Jul 3, 2012 at 4:10 PM, Rob Spanton <rspanton at zepler.net> wrote:
> I was recently working on an embedded system that had a daemon that
> depended on the presence of two USB serial devices. The daemon needed
> to be run when both devices were plugged in. If any of the devices was
> unplugged, the daemon would exit, and would need to be restarted the
> next time both devices were plugged in.
>
> I created a service file pretty-much like the one at the end of this
> email. This kind-of did what I wanted for a short while. However, if
> the daemon was running, and then I unplugged the serial devices, systemd
> seemed to attempt to continuously restart the daemon despite the serial
> devices not being present. Furthermore, it seemed to give up doing this
> after some period of time (not sure exactly how long, but somewhere
> around minute or two). Once it had given up restarting the daemon, the
> daemon was not restarted when I plugged the devices back in again.
>
> In the end, due to looming deadlines, I added a cron job that just ran
> `systemctl start mydaemon.service` every minute to ensure that systemd
> didn't give up on reactivating the service.
>
> Am I missing something here? Is this a valid application of systemd?
>
> Oh, and this is with systemd-44 (Fedora systemd-44-17.fc17.i686).
why not write a middle-man layer that uses socket activation?
alternatively, you could use inotify and immediately start your daemon.
Auke
More information about the systemd-devel
mailing list