Re: [systemd-devel] dependent services status
On Do, 17.11.22 08:52, Ted Toth (txt...@gmail.com) wrote: > I have a set of services that depend on each other however when > services are started and considered 'active' that does not necessarily > mean they are in a state that a dependent service requires them to be > in to operate properly (for example an inotify watch has been > established). This is a bug in those services. THey should not report startup completion when they haven't completed startup. Part of startup is considered evertyhing like "establish sockets", "establish inotify watches" and so on... > systemd services, I think, have a substate, is there a > way I can set that to a custom value to indicate the services idea of > its own state? For Type=notify services use sd_notify("READY=1") to communicate startup completion. For Type=forking serviecs exit in the parent process when the main service process finished startup. Lennart -- Lennart Poettering, Berlin
Re: [systemd-devel] dependent services status
On Fri, Nov 18, 2022 at 5:33 PM Barry wrote: > > > > > On 17 Nov 2022, at 20:03, Ted Toth wrote: > > > > The comment about inotify was just an example, I understand that there > > is a 'notify' service type but I'm not using it because of its > > documented shortcomings. > > I thought using sd_notify would be all advantages. > Service gets to set its state explicitly, no need for systemd to guess. > > What are the shortcomings you are referring to? Sorry I was thinking about systemd-path which I had looked at as an option for watching a directory for file creation. I hadn't looked at sd_notify yet, thanks for the suggestion. > > Barry > > > > > >> On Thu, Nov 17, 2022 at 11:34 AM Alvin Šipraga > >> wrote: > >> > >> Hi Ted, > >> > >>> On Thu, Nov 17, 2022 at 08:52:00AM -0600, Ted Toth wrote: > >>> I have a set of services that depend on each other however when > >>> services are started and considered 'active' that does not necessarily > >>> mean they are in a state that a dependent service requires them to be > >>> in to operate properly (for example an inotify watch has been > >>> established). systemd services, I think, have a substate, is there a > >>> way I can set that to a custom value to indicate the services idea of > >>> its own state? > >> > >> If you set Type=notify in the [Service] block of the service definition > >> file, you can use the sd_notify(3) API: > >> > >> https://www.freedesktop.org/software/systemd/man/sd_notify.html > >> > >> Is that what you are looking for? > >> > >> Kind regards, > >> Alvin > > >
Re: [systemd-devel] dependent services status
> On 17 Nov 2022, at 20:03, Ted Toth wrote: > > The comment about inotify was just an example, I understand that there > is a 'notify' service type but I'm not using it because of its > documented shortcomings. I thought using sd_notify would be all advantages. Service gets to set its state explicitly, no need for systemd to guess. What are the shortcomings you are referring to? Barry > > >> On Thu, Nov 17, 2022 at 11:34 AM Alvin Šipraga wrote: >> >> Hi Ted, >> >>> On Thu, Nov 17, 2022 at 08:52:00AM -0600, Ted Toth wrote: >>> I have a set of services that depend on each other however when >>> services are started and considered 'active' that does not necessarily >>> mean they are in a state that a dependent service requires them to be >>> in to operate properly (for example an inotify watch has been >>> established). systemd services, I think, have a substate, is there a >>> way I can set that to a custom value to indicate the services idea of >>> its own state? >> >> If you set Type=notify in the [Service] block of the service definition >> file, you can use the sd_notify(3) API: >> >> https://www.freedesktop.org/software/systemd/man/sd_notify.html >> >> Is that what you are looking for? >> >> Kind regards, >> Alvin >
Re: [systemd-devel] dependent services status
The comment about inotify was just an example, I understand that there is a 'notify' service type but I'm not using it because of its documented shortcomings. On Thu, Nov 17, 2022 at 11:34 AM Alvin Šipraga wrote: > > Hi Ted, > > On Thu, Nov 17, 2022 at 08:52:00AM -0600, Ted Toth wrote: > > I have a set of services that depend on each other however when > > services are started and considered 'active' that does not necessarily > > mean they are in a state that a dependent service requires them to be > > in to operate properly (for example an inotify watch has been > > established). systemd services, I think, have a substate, is there a > > way I can set that to a custom value to indicate the services idea of > > its own state? > > If you set Type=notify in the [Service] block of the service definition > file, you can use the sd_notify(3) API: > > https://www.freedesktop.org/software/systemd/man/sd_notify.html > > Is that what you are looking for? > > Kind regards, > Alvin
Re: [systemd-devel] dependent services status
Hi Ted, On Thu, Nov 17, 2022 at 08:52:00AM -0600, Ted Toth wrote: > I have a set of services that depend on each other however when > services are started and considered 'active' that does not necessarily > mean they are in a state that a dependent service requires them to be > in to operate properly (for example an inotify watch has been > established). systemd services, I think, have a substate, is there a > way I can set that to a custom value to indicate the services idea of > its own state? If you set Type=notify in the [Service] block of the service definition file, you can use the sd_notify(3) API: https://www.freedesktop.org/software/systemd/man/sd_notify.html Is that what you are looking for? Kind regards, Alvin
Re: [systemd-devel] dependent services status
On Thu, Nov 17, 2022 at 08:52:00AM -0600, Ted Toth wrote: > I have a set of services that depend on each other however when > services are started and considered 'active' that does not necessarily > mean they are in a state that a dependent service requires them to be > in to operate properly (for example an inotify watch has been > established). systemd services, I think, have a substate, is there a > way I can set that to a custom value to indicate the services idea of > its own state? For any given service, I sometimes introduce a ExecStartPost that would block until some resource is consumed (network port opened, lock created, whatever). Perhaps not the most efficient, but that's how I've enforced 'really up'. > Ted -- Brian Reichert BSD admin/developer at large
[systemd-devel] dependent services status
I have a set of services that depend on each other however when services are started and considered 'active' that does not necessarily mean they are in a state that a dependent service requires them to be in to operate properly (for example an inotify watch has been established). systemd services, I think, have a substate, is there a way I can set that to a custom value to indicate the services idea of its own state? Ted