From eaf71db7c95ea08999d5d83efeb7fa3d64b918fc Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Tue, 10 Mar 2015 00:43:33 -0500 Subject: [PATCH] Fix syncthing process reparenting with runit When you: `sudo sv down /etc/service/syncthing/` the `TERM` signal isn't propogated or trapped, so syncthing is orphaned and adopted by init (PID 1). - Changed call to `chpst` to `exec` - Moved logging to `log/run` per `runsv` standard --- etc/linux-runit/README.md | 3 ++- etc/linux-runit/log/run | 4 ++++ etc/linux-runit/run | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100755 etc/linux-runit/log/run diff --git a/etc/linux-runit/README.md b/etc/linux-runit/README.md index 2586f569a..739f6823c 100644 --- a/etc/linux-runit/README.md +++ b/etc/linux-runit/README.md @@ -9,7 +9,8 @@ other platforms also using runit. recommended to place it in a directory writeable by the running user so that automatic upgrades work. - 3. Copy the edited `run` file to `/etc/service/syncthing/run`. + 3. Copy this directory (containing the edited `run` file and `log` folder) to + `/etc/service/syncthing`. Log output is sent to syslogd. diff --git a/etc/linux-runit/log/run b/etc/linux-runit/log/run new file mode 100755 index 000000000..04eec1560 --- /dev/null +++ b/etc/linux-runit/log/run @@ -0,0 +1,4 @@ +#!/bin/sh + +exec logger -t syncthing + diff --git a/etc/linux-runit/run b/etc/linux-runit/run index 9e9352703..497066b93 100644 --- a/etc/linux-runit/run +++ b/etc/linux-runit/run @@ -4,5 +4,6 @@ export USERNAME=jb export HOME="/home/$USERNAME" export SYNCTHING="$HOME/bin/syncthing" -chpst -u "$USERNAME" "$SYNCTHING" -logflags 0 2>&1 | logger -t syncthing +exec 2>&1 +exec chpst -u "$USERNAME" "$SYNCTHING" -logflags 0