Problem with restart after automatic update

Hi everyone,

i have a problem with the automatic update. The Systems i use are based on CentOS 7 on x86_64 hardware. Iam running syncthing with a non privileged user ‘syncthing’ and using this unitfile (unser /etc/systemd/system) for starting the programm or manually run with systemctl start syncthing@syncthing

[Unit]
Description=Syncthing for %i

[Service] 
Type=simple
User=%i
ExecStart=/syncthing/syncthing
WorkingDirectory=%h

[Install]
WantedBy=multi-user.target

The problem i have is that syncthing wont start after an automatic update. Here is what the log says:

Mär 11 21:59:53 buxv145.lan syncthing[3538]: [X7LHQ] 21:59:53 INFO: Automatic upgrade (current "v0.10.25" < latest "v0.10.26")
Mär 11 22:00:03 buxv145.lan syncthing[3538]: [X7LHQ] 22:00:03 WARNING: Automatically upgraded to version "v0.10.26". Restarting in 1 minute.
Mär 11 22:01:03 buxv145.hv.lan syncthing[3538]: [X7LHQ] 22:01:03 OK: Exiting
Mär 11 22:01:03 buxv145.hv.an syncthing[3538]: [monitor] 22:01:03 INFO: Restarting monitor...

This is all what will happen, after the try to restart the monitor nothing will happen. If I start the programm manually, it starts normaly. Did anyone have the same Problem or find a solution to fix this?

Don’t know, if i have exactly same problem, i wouldn’t even call it a problem:

On my 2 NAS servers (debian) I’m running syncthing manually and everytime one of my syncthing nodes updates it restarts and i get same output with last line “Restarting monitor…” but syncthing is running and everything works just fine. Only i have to manually shut it down and start again from console so i could see output. I guess it has something to do with the fact that after restart different binary file is executed. But I’m only guessing here, so any dev care to explain? Thanks in advance.

Well at the point the process restarts we’ve lost stdin stdout to the old console, hence why output is lost. You can setup a bash script which restarts syncthing (and has no monitor) and then redirect the output to a file.

As for the first post, I think syncthing starts fine, just the service manager looses the output. Alternatively, the svc mgr script should be changed to replace the monitor and handle syncthings exit codes properly. These are already shipped with the release in the /etc/ dir for different svc managers.

Please do try the systemd configs suggested in the etc dir. You’re missing out on at least some environment variables that affect this.

Thanks for your awnsers, I had taken a look on the configuration sample in the /etc directory to modify my config this way:

[Unit]
Description=Syncthing for %i
After=network.target

[Service]
Type=simple
User=%i
Environment=STNORESTART=yes
ExecStart=/syncthing/syncthing
WorkingDirectory=%h
Restart=on-failure
RestartPreventExitStatus=1
SuccessExitStatus=2
RestartForceExitStatus=3 4

[Install]
WantedBy=multi-user.target

I think, i will see if it works on next automatic update.

I have made some testing with this unit file and the update from version 0.10.24 to 0.10.26 and it works :smile: so this problem is solved for me - thanks!