On 4/19/19 9:09 PM, Ludovic Courtès wrote: > Hi, > > rendaw <[email protected]> skribis: > >> I think fundamentally what I'd most like to know is when should I use a >> Shepherd service vs a non-Shepherd service. Maybe it's as simple as: if >> you don't have any specific requirements always define a Shepherd service. > It’s hard to answer that question in the abstract. Do you have an > example in mind that we could work through?
Yeah, so the basic example I was thinking of is I have an executable binary (a server for diagnostics) I'd like to run when the computer boots. > >> Beyond what a service actually is though I have a few more questions: >> >> * Both >> https://www.gnu.org/software/guix/manual/en/html_node/Service-Composition.html >> and >> https://www.gnu.org/software/guix/manual/en/html_node/Shepherd-Services.html#Shepherd-Services >> appear to show a dependency graph. > The first page shows a service extension graph. > > The second page shows a graph of dependencies among Shepherd services. > > These are two different beasts. Ah okay, that explains a lot - I was completely misinterpreting the extension graph then. I'm afraid I don't know what extension means in this context. Is it similar to OOP extension, where a "Dog" is-a "Canine"? Looking at the graphic, "accounts" depends-on "etc" (the directory/mount?) makes a lot more sense to me than "accounts" is-a "etc". Similarly I would assume that the udev service runs udevd, but if upower and colord are both "udev" services (because they extend udev) does that mean if I run both the upower and colord services then my system will have 3 instances of udevd running? I'm fairly sure that's not what it means, but if extends isn't an inheritance relationship and it's not a dependency relationship I'm not sure what it is. Is the udev service in the shepherd graph different then the udev service (-type?) in the service extension graph? That might be a factor in my confusion. >> Are the dependency graphs Shepherd and non-Shepherd services >> entirely separate? Or maybe I'm completely misunderstanding >> "extension" in this context. Can an inet service depend on a non-inet >> service? Can an inet service depend on a d-bus service? * Is there a >> way to hook into service events - that is, run some code when a >> service starts or stops? > An inetd service cannot “depend” on a non-inetd service; a D-Bus service > cannot depend on a non-D-Bus service. Both D-Bus and inetd have their > own notion of what a service is, how to start it, etc., which is > separate from what the Shepherd does. So suppose I have an mcron job that needs an ssh tunnel managed by shepherd to be started, or an inetd handler that needs data files on a network mount to run... is it possible to express those ordering dependencies? Or a service that subscribes the server to external webhooks, and needs the webhook listeners (inetd handlers) to be started before registering. I assume the answer to my 2nd question from the previous email - if there's a way to run code when a service's state changes - is that there currently isn't such hooking mechanism. > > I reckon that calling everything a “service” does not help understand > all this… I don't think it's an unreasonable choice of words :) - there's just a lot that isn't fitting in mentally for me. And thank you for your patience with the answers, I think I'm drawing much closer to understanding all this. Once I've figured it out I'll definitely write something up in case someone else has the same issues.
