From: Rich Freeman <rich0@gentoo.org>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] sysV/openrc init script vs. systemd .service file
Date: Mon, 11 Aug 2014 17:03:00 -0400 [thread overview]
Message-ID: <CAGfcS_ksGkCv4bg7PX7kJb6_GgHPGN0ecCS+RmSVk30DxgqvxQ@mail.gmail.com> (raw)
In-Reply-To: <lsb7m3$v36$1@ger.gmane.org>
On Mon, Aug 11, 2014 at 4:05 PM, Grant Edwards
<grant.b.edwards@gmail.com> wrote:
>
> Any advice on whether it would be easier to use a common init script
> with sysV/OpenRC/systemd or to write a separate .service file?
I'd almost certainly generate a proper unit, and not try to use a
compatibility mode, especially if you're generating these using
software. If anything it would make more sense to make a sysvinit
script which is a wrapper for a systemd unit than the other way
around.
Sysvinit scripts are just that - touring-complete scripts.
Systemd units are declarative.
Here is the Gentoo mysqld unit, which is pretty simple:
[Unit]
Description=MySQL database server
After=syslog.target
After=network.target
[Service]
Type=simple
User=mysql
Group=mysql
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# https://bugzilla.redhat.com/show_bug.cgi?id=547485
ExecStart=/usr/bin/mysqld_safe --basedir=/usr
ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# We rely on systemd, not mysqld_safe, to restart mysqld if it dies
Restart=always
# Place temp files in a secure directory, not /tmp
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Most daemons will be fairly similar to this, though a daemon which
forks will be slightly different (type=forking, and will have a
PIDfile setting). This one is a bit fancy in that it has a post-exec
script/program that just checks for the main service to be ready (so
that reverse dependencies aren't started prematurely).
It is important that whatever is in execstart doesn't die if this is a
daemon. If this is just going to modprobe something and terminate
that is fine, but there is a slightly different way to express those
so that it isn't considered a failure.
Rich
next prev parent reply other threads:[~2014-08-11 21:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-11 20:05 [gentoo-user] sysV/openrc init script vs. systemd .service file Grant Edwards
2014-08-11 21:03 ` Rich Freeman [this message]
2014-08-11 21:55 ` [gentoo-user] " Grant Edwards
2014-08-12 0:43 ` Rich Freeman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGfcS_ksGkCv4bg7PX7kJb6_GgHPGN0ecCS+RmSVk30DxgqvxQ@mail.gmail.com \
--to=rich0@gentoo.org \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox