Re: [systemd-devel] [PATCH v3] systemd.service(5): add some simple examples
On Tue, 27.01.15 22:10, Christian Seiler (christ...@iwakd.de) wrote: Thanks a ton! Applied! > Am 27.01.2015 um 21:45 schrieb Lennart Poettering: > > On Tue, 27.01.15 17:45, Christian Seiler (christ...@iwakd.de) wrote: > >> +Note that systemd assumes here that the > >> +program will continue running in the foreground > >> +as long as it's active. If the program > > > > I think "foreground" vs. "background" here is probably something to > > avoid. These are services after all, and hence kinda "background" in > > all cases. I am not sure how to explain this better though... Maybe > > clarify that the program does not fork on its own, and that the > > process systemd starts stays running until the very end of the > > daemon, or so. > > Yes, you are completely right. I've kept the use of 'background' at some > places, but specifically avoided foreground, since that is really, > really misleading. I've also rephrased the paragraph in question. I hope > that's better. > > >> +Note that systemd will consider the unit > >> +to be in the state 'starting' until the program > >> +has terminated, so ordered dependencies will > >> +wait for the program to finish before starting > >> +themselves. The unit will revert to the > >> +'inactive' state after the execution is > >> +done. That means another request to start the > >> +unit will perform the action again. > > > > It might be worth also mentioning here that the the unit this way will > > never actually be "active". It will go directly from "activating" to > > "inactive", which might be surprising! > > Thanks for the pointer, done! > > Now I also mentioned something about multiple ExecStart= for oneshot > units, which might be useful there. > > >> +Similarly to the oneshot services, there > >> +are sometimes units that need to execute a > >> +program to set up something and then execute > >> +another to shut it down, but no process remains > >> +active while they are considered > >> +'started'. Network configuration can sometimes > >> +fall into this category. > > > > Another reason to use RemainAfterExit= are services that shall not > > execute again and again when they are pulled in, but only the first > > time... > > Mentioned that, thanks! > > >> RemainAfterExit=dbus > > > > Typo. Should be Type=, not RemainAfterExit= > > *hehe* fixed. > > >> + > >> +Deferred (idle) services > > > > Hmm, I wonder if we maybe should remove this part. Idle services are > > kinda exotic, and I figure people might be tempted to misuse them. I > > think this might be something to document at the description of Type=, > > but not push people towards using this beyond that. > > When I started writing this, I didn't just want to copy the getty > service (people can look that up anyway), so I decided to come up with > something else. However, once I wrote that unit, I realized that this > could have easily just been a Type=oneshot, RemainAfterExit=yes, > After=multi-user.target unit and have the same effect, and be a lot more > consistent with the rest of the way of doing things... > > Type=idle is basically really just for gettys or something extremely > similar (like other interactive apps on VTs) that also get automatically > restarted. > > Since these examples are supposed to provide a starting point for people > on how to write services, I've removed the section completely, and I > think this kind of special internal thing should remain in the reference > documentation. > > v3 attached, I also fixed one or two other minor typos I noticed. > > Christian > > From ff44c16a173b36695e4844b36fbd10ac977bf4a3 Mon Sep 17 00:00:00 2001 > From: Christian Seiler > Date: Tue, 27 Jan 2015 17:38:02 +0100 > Subject: [PATCH] systemd.service(5): add some simple examples > > Add a couple of exampels, at least one for each service type that > include some explanations and pointers to various relevant options. > --- > man/systemd.service.xml | 296 > > 1 file changed, 296 insertions(+) > > diff --git a/man/systemd.service.xml b/man/systemd.service.xml > index 4c890df..f33e8df 100644 > --- a/man/systemd.service.xml > +++ b/man/systemd.service.xml > @@ -1358,6 +1358,302 @@ ExecStart=/bin/echo $ONE $TWO $THREE > > > > +Examples > + > + > +Simple service > + > +The following unit file creates a service > +that will execute > +
[systemd-devel] [PATCH v3] systemd.service(5): add some simple examples
Am 27.01.2015 um 21:45 schrieb Lennart Poettering: > On Tue, 27.01.15 17:45, Christian Seiler (christ...@iwakd.de) wrote: >> +Note that systemd assumes here that the >> +program will continue running in the foreground >> +as long as it's active. If the program > > I think "foreground" vs. "background" here is probably something to > avoid. These are services after all, and hence kinda "background" in > all cases. I am not sure how to explain this better though... Maybe > clarify that the program does not fork on its own, and that the > process systemd starts stays running until the very end of the > daemon, or so. Yes, you are completely right. I've kept the use of 'background' at some places, but specifically avoided foreground, since that is really, really misleading. I've also rephrased the paragraph in question. I hope that's better. >> +Note that systemd will consider the unit >> +to be in the state 'starting' until the program >> +has terminated, so ordered dependencies will >> +wait for the program to finish before starting >> +themselves. The unit will revert to the >> +'inactive' state after the execution is >> +done. That means another request to start the >> +unit will perform the action again. > > It might be worth also mentioning here that the the unit this way will > never actually be "active". It will go directly from "activating" to > "inactive", which might be surprising! Thanks for the pointer, done! Now I also mentioned something about multiple ExecStart= for oneshot units, which might be useful there. >> +Similarly to the oneshot services, there >> +are sometimes units that need to execute a >> +program to set up something and then execute >> +another to shut it down, but no process remains >> +active while they are considered >> +'started'. Network configuration can sometimes >> +fall into this category. > > Another reason to use RemainAfterExit= are services that shall not > execute again and again when they are pulled in, but only the first > time... Mentioned that, thanks! >> RemainAfterExit=dbus > > Typo. Should be Type=, not RemainAfterExit= *hehe* fixed. >> + >> +Deferred (idle) services > > Hmm, I wonder if we maybe should remove this part. Idle services are > kinda exotic, and I figure people might be tempted to misuse them. I > think this might be something to document at the description of Type=, > but not push people towards using this beyond that. When I started writing this, I didn't just want to copy the getty service (people can look that up anyway), so I decided to come up with something else. However, once I wrote that unit, I realized that this could have easily just been a Type=oneshot, RemainAfterExit=yes, After=multi-user.target unit and have the same effect, and be a lot more consistent with the rest of the way of doing things... Type=idle is basically really just for gettys or something extremely similar (like other interactive apps on VTs) that also get automatically restarted. Since these examples are supposed to provide a starting point for people on how to write services, I've removed the section completely, and I think this kind of special internal thing should remain in the reference documentation. v3 attached, I also fixed one or two other minor typos I noticed. Christian From ff44c16a173b36695e4844b36fbd10ac977bf4a3 Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Tue, 27 Jan 2015 17:38:02 +0100 Subject: [PATCH] systemd.service(5): add some simple examples Add a couple of exampels, at least one for each service type that include some explanations and pointers to various relevant options. --- man/systemd.service.xml | 296 1 file changed, 296 insertions(+) diff --git a/man/systemd.service.xml b/man/systemd.service.xml index 4c890df..f33e8df 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -1358,6 +1358,302 @@ ExecStart=/bin/echo $ONE $TWO $THREE +Examples + + +Simple service + +The following unit file creates a service +that will execute +/usr/sbin/foo-daemon. +Since no Type= is specified, +the default +Type=simple +will be assumed. systemd will assume the unit +to be started immediately after the program has +