You are not logged in.
The service file /usr/lib/systemd/system/insync@.service of the Insync synchronisation tool looks as follows:
[Install]
WantedBy=multi-user.target
[Unit]
Description=Insync
After=local-fs.target network.target
[Service]
Type=simple
Environment=DISPLAY=:-0
ExecStart=/usr/bin/insync start
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
User=%I
[Install]
WantedBy=multi-user.targetWhen running # systemctl stop insync@<user>.service, systemctl reports that the service has stopped.
Jan 14 07:05:12 thinkpad systemd[1]: Stopped Insync.However, Insync is still running:
➜ ~ ps aux | grep insync
orschiro 2792 0.6 1.7 1046004 139272 ? Sl 06:36 0:12 ./insync startThe service file looks exactly the same as the Dropbox one for which killing the service on stop is working.
Why does it not work in this case?
Last edited by orschiro (2014-01-18 08:16:05)
Offline
I don't use this Insync at all, but it makes me wonder why there is the need to set KillMode=process. When the service is running, is there more than one process in the service's cgroup? If so, then setting KillMode=process doesn't seem to make much sense.
See the man page for systemd.kill.
Offline
Yes, I think there is. When removing KillMode=process, I get this:
➜ ~ sudo systemctl status insync@orschiro.service
insync@orschiro.service - Insync
Loaded: loaded (/usr/lib/systemd/system/insync@.service; disabled)
Active: active (running) since Tue 2014-01-14 07:12:46 CET; 105ms ago
Main PID: 8670 (insync)
CGroup: /system.slice/system-insync.slice/insync@orschiro.service
├─8670 /bin/bash /usr/bin/insync start
├─8671 ./insync start
└─8683 ./insync start
Jan 14 07:12:46 thinkpad systemd[1]: insync@orschiro.service holdoff time over, scheduling restart.
Jan 14 07:12:46 thinkpad systemd[1]: Stopping Insync...
Jan 14 07:12:46 thinkpad systemd[1]: Starting Insync...
Jan 14 07:12:46 thinkpad systemd[1]: Started Insync.Offline
Okay, so you see that there are child processes there. Now go to the man page, and read what KillMode=process does and what you might do to fix it.
Offline
@WonderWoofy
Thanks. I looked into the man pages and guess I have to use KillMode=control-group then. However, the main process still keeps running. Am I correct here that KillMode set in /etc/systemd/system/insync@.service should actually take precedence over the one in /usr/lib?
➜ ~ /etc/systemd/system/insync@.service
.include /usr/lib/systemd/system/insync@.service
[Service]
KillMode=control-group➜ ~ cat /usr/lib/systemd/system/insync@.service
[Unit]
Description=Insync
After=local-fs.target network.target
[Service]
ExecStartPre=/usr/bin/sleep 60
Environment=DISPLAY=:0
Type=simple
ExecStart=/usr/bin/insync start
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
User=%I
[Install]
WantedBy=multi-user.targetJan 15 09:15:16 thinkpad systemd[1]: Stopped Insync.➜ ~ ps aux | grep insync
orschiro 26324 1.2 1.6 1111784 136516 ? Sl 08:57 0:13 ./insync startOffline
I have managed to come up with a working service file that successfully stops Insync when running systemctl stop insync@<user>.service.
Thanks again for your help.
[Unit]
Description=Insync
After=local-fs.target network.target
[Service]
Environment=DISPLAY=:0
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/insync start
ExecStop=/usr/bin/insync quit
User=%I
[Install]
WantedBy=multi-user.targetOffline