▲ | simoncion 6 days ago | ||||||||||||||||
> /etc/init.d/whatever were all shell scripts, and they all had to implement all the features themselves. A minimal SystemD service file and a minimal OpenRC service file are equally complex. Here's the OpenRC service file for ntpd (which is not a minimal service file, but is pretty close):
'depend' handles service dependency declaration and start/stop ordering (obviously).'start_pre' is a sanity check that could be removed, or reduced to calling an external script (just like -IIRC- systemd forces you to do). There are _pre and _post hooks for both start and stop. For a service that has no dependencies on other services, backgrounds itself, and creates a pidfile automatically, the smallest OpenRC service file is four non-blank lines: the '#!/sbin/openrc-run' shebang followed by lines declaring 'pidfile', 'command', and 'command_args'. A program that runs only in the foreground adds one more line, which tells OpenRC to handle daemonizing the thing and writing its pidfile: 'command_background="true"'. See [3] for an example of one such service file. If you want service supervision, it's as simple as adding 'supervisor=supervise-daemon', and ensuring that your program starts in the foreground. If it doesn't foreground itself automatically, then adding 'command_args_foreground=<Program Foregrounding Args>' will do the trick. If you're interested in more information about OpenRC service file syntax, check out the guide for them at [0], and for a lot more information, the manual for openrc-run at [1]. For supervision, check out the supervision guide at [2]. [0] <https://github.com/OpenRC/openrc/blob/master/service-script-...> [1] <https://man.uex.se/8/openrc-run> [2] <https://github.com/OpenRC/openrc/blob/master/supervise-daemo...> [3] The OpenRC service file for the 'cups-browsed' service (which is a program that does not daemonize itself) is this:
| |||||||||||||||||
▲ | dale_glass 6 days ago | parent [-] | ||||||||||||||||
So on one hand, yes, that's a vast improvement over SysV. On the other hand, no sir, I still don't like it. It looks very much like Bash. I'm not very fond of Bash to start with and it might not even be actual Bash? Can't tell from the manpage. But scrolling down to the bottom of the manpage I see a pretty long sample script, and that's exactly what I want to see completely gone. I don't want to look at a 3-way way merge of a service during an upgrade ever again and try and figure out what's all that jank doing. IMO if any of that shell scripting has any reason to be in a service file, it's a bug to be fixed. My ideal is the simple systemd services: description, dependencies, one command to start, done. No jank with cleaning up temp files, or signals, or pid files (can they please die already), or any of that. And one of the nice things about systemd services not being a script is that overrides are straightforward and there's never any diffs involved. | |||||||||||||||||
|