Syncthing fails to start as ubuntu systemd service

2

I recently setup a home server running ubuntu 16.04. I installed syncthing on it to sync between my desktop, laptop, and phone.

So I want syncthing to run as a system service, meaning the service starts when the PC starts, without me having to log in, but I want it to sync the files in my personal user's home directory (/home/ryan/Sync).

I followed the instructions here, but I'm having an issue where the service fails to start upon system boot. Here is what I see upon logging in and checking the status...

enter image description here

Then, all I have to do is run systemctl start syncthing@ryan.service and it works fine; but I just want it to start without me having to log in and run the command.

Ryan Stull

Posted 2016-10-03T02:52:26.590

Reputation: 135

Answers

0

The problem had something to do with my encrypted home directory. I guess the OS couldn't start a syncthing process under my local user until I logged in an decrypted my home directory.

In the end I just decided to remove the encryption on my home dir by following these instructions.

Everything works great now!

Ryan Stull

Posted 2016-10-03T02:52:26.590

Reputation: 135

1

If you want to keep the home folder encrypted and use a system service to sync data from an unencrypted part of your file system, you need to move the location of the Syncthing config folder (home/{myuser}/.config/syncthing by default) out of the encrypted home directory, by using the -home="/path/to/config argument when running Syncthing.

For example;

  • Enable the service, $ sudo systemctl enable syncthing@{myuser}.service, and take note of the location of syncthing@.service (e.g. /lib/systemd/system/syncthing@.service).
  • Modify the service sudo nano /lib/systemd/system/syncthing@.service, adding -home="/path/to/.config/syncthing" to the ExecStart= line;

    [Unit]
    Description=Syncthing - Open Source Continuous File Synchronization for %I
    Documentation=man:syncthing(1)
    After=network.target
    Wants=syncthing-inotify@.service
    
    [Service]
    User=%i
    ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0 -home="/path/to/.config/syncthing"
    Restart=on-failure
    SuccessExitStatus=3 4
    RestartForceExitStatus=3 4
    
    [Install]
    WantedBy=multi-user.target
    
  • Start the service, $ sudo systemctl start syncthing@{myuser}.service, and check the config files have been added to the given path.
  • Restart and check the service was already up and running once you log in, $ systemctl status syncthing@{myuser}.service.

n.b. Make sure not to sync the config folder itself.

gamdow

Posted 2016-10-03T02:52:26.590

Reputation: 11

0

You can enable it as a startup program in Ubuntu so it starts at login instead of using systemctl.

Search the HUD for Startup Applications Choose Add

Name it Syncthing

In 16.04 the command will be /usr/bin/syncthing -no-browser -home="/home/youruserfolder/.config/syncthing" replacing youruserfolder.

Add a comment.

Save by clicking add.

Log back out and then in and check your status by going to http://127.0.0.1:8384/

masonbee

Posted 2016-10-03T02:52:26.590

Reputation: 1