dinit icon indicating copy to clipboard operation
dinit copied to clipboard

external readiness notification mechanism

Open q66 opened this issue 3 years ago • 1 comments

I wonder if it would be worthwhile to implement another mechanism for readiness notification of services. Currently we can do that from the service itself using a file descriptor passed either directly or through an environment variable. This is a simple and fairly flexible mechanism, but it cannot be applied universally.

I was thinking of possibly introducing a new mechanism that would utilize some kind of ready-command field. I'm thinking the system could simply do:

  1. If present, issue the command alongside the service's command
  2. Wait for the ready-command to exit
  3. If the exit status of it was 0, service is considered ready
  4. In case of a non-zero exit status, bring down the service

This could be adapted to lots of things that do not directly support any kind of readiness notification. In my particular case I would use this for the dbus activation support I am working on (the command would take care of waiting for the service to appear on the bus).

WDYT?

q66 avatar Jul 28 '22 05:07 q66

Yes, seems reasonable

davmac314 avatar Jul 28 '22 09:07 davmac314

I think that, while it's a bit clunky, you could probably achieve the same overall effect using multiple services:

  • a master service, which depends on the other two
  • a process or bgprocess service for the service process itself
  • a scripted service which is the readiness notification

The master service state will only become "started" once both the underlying services are started, meaning that the readiness check must have completed. I hope that makes sense.

davmac314 avatar Jan 07 '23 10:01 davmac314

i guess that could work, but yeah it's a tad clunky (maybe it wouldn't matter that much in my use case though)

q66 avatar Jan 09 '23 15:01 q66

i think this could even be done with just two services? the readiness service would be scripted and depend on the actual process service; if the process service does not have a readiness check, it would immediately be started, followed by the scripted one, which would wait for the script to finish, itself becoming started

q66 avatar Jan 09 '23 15:01 q66

Yep, that should work I think

davmac314 avatar Jan 09 '23 21:01 davmac314

this can actually be implemented with one command, i've already done so for what i had in mind: https://github.com/chimera-linux/dbus-wait-for

so i think there is no need to have this feature in dinit

q66 avatar Nov 03 '23 22:11 q66

Ok, closing at least for now.

davmac314 avatar Dec 03 '23 02:12 davmac314