How to run an app as a daemon with systemd?

2.3k Views Asked by At

I'd like to run syncthing as a daemon, trying to follow this hint here from the syncthing manual.

I'm running on Fedora 25 and syncthing 0.14.24.

The executable is pointed to via a symlink in /usr/bin/syncthing which can be executed by any user (tested this successfully).

To enable the service, I'm typing (myuser is replaced with my actual username in all of the below):

sudo systemctl enable [email protected]

Which returns:

Failed to lookup unit file state: Invalid argument

I don't understand what the error message means. How could I get to run syncthing as a daemon?


[email protected]:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
[email protected]  # I also commented this line out; didn't have an effect

[Service]
User=%i
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=multi-user.target
1

There are 1 best solutions below

4
On

I think myuser should be substituted for your actual username.

Arch wiki has a pretty good article:

System service

Running Syncthing as a system service ensures that it is running at startup even if the user has no active session, it is intended to be used on a server.

Enable and start the [email protected] where myuser is the actual name of your user.

Credit: https://wiki.archlinux.org/index.php/Syncthing