Systemd on vivid beta

Tom H tomh0665 at gmail.com
Mon Mar 9 21:13:38 UTC 2015


On Mon, Mar 9, 2015 at 2:08 PM, Tom H <tomh0665 at gmail.com> wrote:
> On Mon, Mar 9, 2015 at 9:34 AM, Colin Law <clanlaw at gmail.com> wrote:
>>
>> That is what I hoped. The problem is with shutdown, but only on power
>> down. I can run systemctl stop myservice.service and it functions
>> correctly, and I can start it again. But if I shutdown it does not
>> seem to be getting the timing right. My init.d script starts
>>
>> #! /bin/sh
>> ### BEGIN INIT INFO
>> # Provides:          automount
>> # Required-Start:    $remote_fs $syslog
>> # Required-Stop:     $remote_fs $syslog
>> # Default-Start:     2 3 4 5
>> # Default-Stop:      0 1 6
>> # Short-Description: Automounts SAMBA shares
>> # Description:       Dynamically (un)mounts specific SAMBA shares.
>> ### END INIT INFO
>>
>> Which I thought should mean that it will complete the stop before
>> shutting down syslog, but I have littered logging through the script
>> and I see a variable number of these displayed in syslog before
>> syslogd quits. Sometimes I do not even see the first one, which is
>> the first executable line in the script. I inherited the script years
>> ago and don't know much about init scripting but the above looks ok,
>> and it works fine in upstart.
>>
>> Am I doing something obviously silly? Alternatively any suggestions
>> to analyse the problem further?
>
> I'd start by adding "$network" to your "Required-Start" and
> "Required-Stop" lines. It might create a better dependency translation
> when a systemd .service unit is generated from the sysvinit script.
>
> Longer-term, you should look into migrating your mounts to systemd .mount units.
>
> More later, sorry.

sysvinit scripts are translated into systemd units by a generator.

apache and samba aren't the same but it's the one daemon that I know
hasn't been systemd-ized yet on my system.

Looking at apache on my laptop:

$ head -n 14 /etc/init.d/apache2
#!/bin/sh
### BEGIN INIT INFO
# Provides:          apache2
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Apache2 web server
# Description:       Start the web server and associated helpers
#  This script will start apache2, and possibly all associated instances.
#  Moreover, it will set-up temporary directories and helper tools such as
#  htcacheclean when required by the configuration.
### END INIT INFO

and

$ cat /run/systemd/generator.late/apache2.service
# Automatically generated by systemd-sysv-generator

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/apache2
Description=LSB: Apache2 web server
Before=runlevel2.target runlevel3.target runlevel4.target
runlevel5.target shutdown.target
After=local-fs.target remote-fs.target network-online.target
systemd-journald-dev-log.socket nss-lookup.target
Wants=network-online.target
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/apache2 start
ExecStop=/etc/init.d/apache2 stop
ExecReload=/etc/init.d/apache2 reload

(FYI, systemd's "Wants" is the same as sysvinit's "Should-Start".)

Look for the systemd unit that corresponds to your sysvinit cifs
script under "/run/systemd/generator{,.late}/". It'll have the same
name plus ".service".




More information about the ubuntu-users mailing list