From c47be7b41547da0d6f50a0bb06ec9ef0cf16f35a Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Wed, 19 Nov 2014 16:42:05 +0800 Subject: [PATCH 1/3] systemd units for system/user --- etc/systemd/system/syncthing@.service | 14 ++++++++++++++ etc/systemd/user/syncthing.service | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 etc/systemd/system/syncthing@.service create mode 100644 etc/systemd/user/syncthing.service diff --git a/etc/systemd/system/syncthing@.service b/etc/systemd/system/syncthing@.service new file mode 100644 index 00000000..f0b6b777 --- /dev/null +++ b/etc/systemd/system/syncthing@.service @@ -0,0 +1,14 @@ +[Unit] +Description=Syncthing service for %i +After=network.target + +[Service] +User=%i +Environment=STARGS= +EnvironmentFile=-/etc/default/syncthing +Environment=STNORESTART=yes +ExecStart=/usr/bin/syncthing ${STARGS} +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/etc/systemd/user/syncthing.service b/etc/systemd/user/syncthing.service new file mode 100644 index 00000000..22f96efa --- /dev/null +++ b/etc/systemd/user/syncthing.service @@ -0,0 +1,12 @@ +[Unit] +Description=Syncthing service + +[Service] +Environment=STARGS= +EnvironmentFile=-%h/.config/syncthing/environment +Environment=STNORESTART=yes +ExecStart=/usr/bin/syncthing ${STARGS} +Restart=always + +[Install] +WantedBy=cmdline.target From 1e8da0d4949ef9f89e4e989b6f7181f46dd92ac3 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Wed, 19 Nov 2014 16:46:14 +0800 Subject: [PATCH 2/3] on-failure instead of always as we cannot otherwise kill the service --- etc/systemd/system/syncthing@.service | 2 +- etc/systemd/user/syncthing.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/systemd/system/syncthing@.service b/etc/systemd/system/syncthing@.service index f0b6b777..5f6ffbd3 100644 --- a/etc/systemd/system/syncthing@.service +++ b/etc/systemd/system/syncthing@.service @@ -8,7 +8,7 @@ Environment=STARGS= EnvironmentFile=-/etc/default/syncthing Environment=STNORESTART=yes ExecStart=/usr/bin/syncthing ${STARGS} -Restart=always +Restart=on-failure [Install] WantedBy=multi-user.target diff --git a/etc/systemd/user/syncthing.service b/etc/systemd/user/syncthing.service index 22f96efa..6f10539f 100644 --- a/etc/systemd/user/syncthing.service +++ b/etc/systemd/user/syncthing.service @@ -6,7 +6,7 @@ Environment=STARGS= EnvironmentFile=-%h/.config/syncthing/environment Environment=STNORESTART=yes ExecStart=/usr/bin/syncthing ${STARGS} -Restart=always +Restart=on-failure [Install] WantedBy=cmdline.target From b9817ac6b46d40e46374f0f243bfa0949a17c110 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 5 Jan 2015 14:25:21 +0800 Subject: [PATCH 3/3] add README --- etc/linux-systemd/README.md | 27 +++++++++++++++++++ .../system/syncthing@.service | 0 .../user/syncthing.service | 0 3 files changed, 27 insertions(+) create mode 100644 etc/linux-systemd/README.md rename etc/{systemd => linux-systemd}/system/syncthing@.service (100%) rename etc/{systemd => linux-systemd}/user/syncthing.service (100%) diff --git a/etc/linux-systemd/README.md b/etc/linux-systemd/README.md new file mode 100644 index 00000000..030e7134 --- /dev/null +++ b/etc/linux-systemd/README.md @@ -0,0 +1,27 @@ +This directory contains a configuration for running syncthing under the +"systemd" service manager on Linux both under either a systemd system service or +systemd user service. + + 1. Install systemd. + + 2. If you are running this as a system level service: + + 1. Create the user you will be running the service as (foo in this example). + + 2. Copy the syncthing@.service files to /etc/systemd/system + + 3. Enable and start the service + systemctl enable syncthing@foo.service + systemctl start syncthing@foo.service + + 3. If you are running this as a user level service: + + 1. Log in as the user you will be running the service as + + 2. Copy the syncthing.service files to /etc/systemd/user + + 3. Enable and start the service + systemctl --user enable syncthing.service + systemctl --user start syncthing.service + +Log output is sent to the journal. diff --git a/etc/systemd/system/syncthing@.service b/etc/linux-systemd/system/syncthing@.service similarity index 100% rename from etc/systemd/system/syncthing@.service rename to etc/linux-systemd/system/syncthing@.service diff --git a/etc/systemd/user/syncthing.service b/etc/linux-systemd/user/syncthing.service similarity index 100% rename from etc/systemd/user/syncthing.service rename to etc/linux-systemd/user/syncthing.service