From 9410477a1ef70bdaaab01125cc31c2b892012132 Mon Sep 17 00:00:00 2001 From: "grawity@2ea26be48562f66fcb9b66307da72b1e2e37453f" Date: Thu, 10 Nov 2016 06:34:44 +0000 Subject: prefer per-user, fix ExecStart syntax --- doc/tips/Systemd_unit.mdwn | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'doc/tips') diff --git a/doc/tips/Systemd_unit.mdwn b/doc/tips/Systemd_unit.mdwn index 4dd7d43af..f56e20dfe 100644 --- a/doc/tips/Systemd_unit.mdwn +++ b/doc/tips/Systemd_unit.mdwn @@ -16,59 +16,59 @@ It can be used as an alternative to XDG autostart files to start the git-annex d ##Setup -### System service +### User service -Sample unit file (`/etc/systemd/system/git-annex@.service`): +Sample unit file (`/etc/systemd/user/git-annex.service`): ``` [Unit] Description=git-annex assistant daemon -After=network.target [Service] -User=%i -ExecStart=git-annex assistant --autostart --foreground +ExecStart=/usr/bin/git-annex assistant --autostart --foreground Restart=on-failure [Install] -WantedBy=multi-user.target +WantedBy=default.target ``` -Commands for enabling and starting the service as user `u`: +Commands for enabling and starting the service as the current user: ``` -systemctl enable git-annex@u.service -systemctl start git-annex@u.service - +systemctl --user enable git-annex.service +systemctl --user start git-annex.service ``` +Usually services in `default.target` start during login. (Note however that they also _delay_ the login process.) However, if you enable "linger" via `loginctl`, then these services start on boot instead. -### User service +### System service -Sample unit file (`/etc/systemd/user/git-annex.service`): +If for some reason you cannot use `systemd --user`, the other option is to have system-wide services: + +Sample unit file (`/etc/systemd/system/git-annex@.service`): ``` [Unit] Description=git-annex assistant daemon +After=network.target [Service] -ExecStart=git-annex assistant --autostart --foreground +User=%i +ExecStart=/usr/bin/git-annex assistant --autostart --foreground Restart=on-failure [Install] -WantedBy=default.target - +WantedBy=multi-user.target ``` -Commands for enabling and starting the service as the current user: +Commands for enabling and starting the service as user `u`: ``` -systemctl --user enable git-annex.service -systemctl --user start git-annex.service +systemctl enable git-annex@u.service +systemctl start git-annex@u.service ``` - --- ## Considerations -- cgit v1.2.3