I love syncthing, I am running it on a WD My Cloud server running Debian GNU Version 7 (with none of the WD software installed). The problem I have is that I am unable to stop logging to the user’s home directory. I want to redirect the logs to /var, which is in RAM, so the disk can spin down when there is no I/O. I am using ramdisk, btw.
Here is my /etc/init.d/syncthing:
#!/bin/sh
### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
# Description: Starts the syncthing daemon for all registered users.
### END INIT INFO
# Replace with users you want to run syncthing clients for
syncthing_USERS="kevinm"
DAEMON=/usr/local/bin/syncthing
DAEMON_START=/usr/local/bin/syncthing_start.sh
startd() {
for stuser in $syncthing_USERS; do
if [ -f $config ]; then
echo "Starting syncthing for $stuser"
start-stop-daemon -b -o -c $stuser -S -u $stuser -x $DAEMON_START
else
echo "Couldn't start syncthing for $stuser (no $config found)"
fi
done
}
stopd() {
for stuser in $syncthing_USERS; do
dbpid=$(pgrep -fu $stuser $DAEMON)
if [ ! -z "$dbpid" ]; then
echo "Stopping syncthing for $stuser"
start-stop-daemon -o -c $stuser -K -u $stuser -x $DAEMON
fi
done
}
status() {
for stuser in $syncthing_USERS; do
dbpid=$(pgrep -fu $stuser $DAEMON)
if [ -z "$dbpid" ]; then
echo "syncthing for USER $stuser: not running."
else
echo "syncthing for USER $stuser: running (pid $dbpid)"
fi
done
}
case "$1" in
start) startd
;;
stop) stopd
;;
restart|reload|force-reload) stopd && startd
;;
status) status
;;
*) echo "Usage: /etc/init.d/syncthing {start|stop|reload|force-reload|restart|status}"
exit 1
;;
esac
From the above, you can see that stop and status use the syncthing binary which is in /usr/local/bin. Starting the daemon calls a script in the same directory called syncthing_start.sh and contains the following:
#!/bin/sh
# Script to make syncthing use syslog.
/usr/local/bin/syncthing 2>&1 | logger -t syncthing
I can see syncthing running two processes:
/etc/init.d/syncthing status syncthing for user: running (pid 32011 32012 32017) ps aux | egrep '32012|32012|32017’ user 32012 0.0 1.2 796676 2960 ? Sl 20:28 0:00 /usr/local/bin/syncthing user 32017 133 27.9 797188 64716 ? Rl 20:28 20:27 /usr/local/bin/syncthing root 32121 0.0 0.3 3100 704 pts/0 S+ 20:43 0:00 egrep 32012|32012|32017
and logger is running
ps aux | grep logger user 32013 0.0 0.2 2944 584 ? S 20:28 0:00 logger -t syncthing root 32213 0.0 0.3 3104 708 pts/0 S+ 21:00 0:00 grep logger
The problem is that syncthing still logs in a verbose manner to the user home directory in /home/user/.config/syncthing/index as well as just info messages /var/log via logger. How can I fix this?