Note

Synthing start on boot with upstart and systemd

SystemV vs Upstart vs Systemd

SystemV uses /etc/init.d. Upstart uses /etc/init and service. service may run scripts from either /etc/init or /etc/init.d (upstart or System V)
Both upstart and systemd are attempts to solve some of the problems with the limitations of the traditional SysV init system. For example, some services need to start after other services (for example, you can't mount NFS filesystems until the network is running), but the only way in SysV to handle that is to set the links in the rc#.d directory such that one is before the other. Add to that, you might need to re-number everything later when dependencies are added or changed. Upstart and Systemd have more intelligent settings for defining requirements. Also, there's the issue with the fact that everything is a shell script of some sort, and not everyone writes the best init scripts. That also impacts the speed of the startup.

SystemV

The scripts in /etc/init.d/ are scripts that control services. Controlling means that they take care of starting, stopping and similar actions. They are not automatically executed at startup. Instead, you must assign scripts to runlevels, which is done with the update-rc.d command on Debian-based systems (which Ubuntu is). For example, to add your supervisor service to all default runlevels, you would execute

sudo update-rc.d supervisor defaults

Upstart

Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. It was originally developed for the Ubuntu distribution, but is intended to be suitable for deployment in all Linux distributions as a replacement for the venerable System-V init.

service syncthing start

Systemd

systemd tutorial

systemctl enable syncthing
systemctl start syncthing

/etc/init/synthing.conf

description "Syncthing P2P sync service"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

env STNORESTART=yes
env HOME=/home/fatminmin
setuid "fatminmin"
setgid "fatminmin"

exec /home/fatminmin/Documents/syncthing-linux-amd64-v0.10.29/syncthing

respawn

/etc/systemd/system/[email protected]

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=https://github.com/syncthing/syncthing/wiki
After=network.target

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

[Install]
WantedBy=multi-user.target