Why can't set syncthing as a service?

sudo vim /etc/systemd/system/syncthing.service
Description=Syncthing - Open Source Continuous File Synchronization

ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening


Set syncthing as a service.

sudo systemctl daemon-reload
sudo systemctl enable syncthing
sudo systemctl start syncthing
sudo systemctl status syncthing

It encounter wrong info:

● syncthing.service - Syncthing - Open Source Continuous File Synchronization
   Loaded: loaded (/etc/systemd/system/syncthing.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Mon 2020-06-01 07:05:47 UTC; 1s ago
     Docs: man:syncthing(1)
  Process: 1332 ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0 (code=exited, status=1/FAILURE)
 Main PID: 1332 (code=exited, status=1/FAILURE)

Jun 01 07:05:47 vultr.guest systemd[1]: syncthing.service: Main process exited, code=exited, status=1/FAILURE
Jun 01 07:05:47 vultr.guest systemd[1]: syncthing.service: Unit entered failed state.
Jun 01 07:05:47 vultr.guest systemd[1]: syncthing.service: Failed with result 'exit-code'.

It is no use to change the

ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0



How to set syncthing as a service ?

The logs should print why it’s exiting. Maybe you’re running a second instance?

ps aux |grep syncthing

It shows that no a second instance there.

When you mean second, you mean any?

Because the service manager is trying to launch a second one, so even one being present would prevent it from running.

Anyways, see if you can launch it from the shell, and if you can, I’d start removing the hardening options one by one.


It is no use to create a new service .just do:

systemctl enable syncthing@root.service
systemctl start syncthing@root.service    

syncthing already prepared that for user.

It’s prepared for any user - there’s almost no reason to run Syncthing as root, unless you have system restrictions on creating users/groups and elevating privileges.

And just for posterity: To see why it didn’t work, check logs e.g. with journalctl -r -u syncthing@yourusername.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.