Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: sysV/openrc init script vs. systemd .service file
Date: Mon, 11 Aug 2014 21:55:52
Message-Id: lsbe43$guu$1@ger.gmane.org
In Reply to: Re: [gentoo-user] sysV/openrc init script vs. systemd .service file by Rich Freeman
1 On 2014-08-11, Rich Freeman <rich0@g.o> wrote:
2 > On Mon, Aug 11, 2014 at 4:05 PM, Grant Edwards
3 ><grant.b.edwards@×××××.com> wrote:
4 >>
5 >> Any advice on whether it would be easier to use a common init script
6 >> with sysV/OpenRC/systemd or to write a separate .service file?
7 >
8 > I'd almost certainly generate a proper unit, and not try to use a
9 > compatibility mode, especially if you're generating these using
10 > software.
11
12 It wouldn't be generated by software. Both the sysv init script and
13 .service file would be maintained by hand.
14
15 > If anything it would make more sense to make a sysvinit script which
16 > is a wrapper for a systemd unit than the other way around.
17
18 Thanks, I'll consider that, but I'm reluctant to do so for fear of
19 breaking compatibility with various ancient systems in use out there.
20 [I can't even find hardware old enough to run some of the Linux
21 kernels and distro's some customers are still using.]
22
23 [...]
24
25 > Most daemons will be fairly similar to this, though a daemon which
26 > forks will be slightly different (type=forking, and will have a
27 > PIDfile setting).
28
29 The daemon is currently of the traditional forking variety with a PID
30 file, so it should lend itself to Type=forking PIDFile=/var/run/whatever.pid.
31
32 But, there are a number of housekeeping tasks that are performed
33 before starting the daemon and after terminating the daemon (checking
34 configuration files, verifying presence of kernel module .ko/.o files,
35 loading a kernel module and logging some pertinent info from that
36 module, unloading the kernel module, etc.). It looks like I should
37 write ExecStartPre and ExecStopPost scripts for systemd to invoke.
38
39 One thing I'm still wondering about is the canonical location to
40 install things like ExecStartPre and ExecStopPost scripts.
41
42 I could modify the daemon to provide a "no-fork" option and then exec
43 it at the end of a startup script, but I don't really see much benefit
44 to that.
45
46 > This one is a bit fancy in that it has a post-exec script/program
47 > that just checks for the main service to be ready (so that reverse
48 > dependencies aren't started prematurely).
49 >
50 > It is important that whatever is in execstart doesn't die if this is
51 > a daemon. If this is just going to modprobe something and terminate
52 > that is fine, but there is a slightly different way to express those
53 > so that it isn't considered a failure.
54
55 Thanks much for the advice.
56
57 --
58 Grant Edwards grant.b.edwards Yow! I am covered with
59 at pure vegetable oil and I am
60 gmail.com writing a best seller!

Replies