Package: transmission-daemon
Version: 2.03-2
Tags: patch
I've improved (IMO) init.d/transmission-daemon script
the changes are:
* PIDFILE
* IOSCHED
* NICE
* increased STOP_TIMEOUT
PIDFILE didn't work because the daemon is started as another user, so
unable to write to the file. --make-pidfile doesn't change ownership
either (may be submit a feature request?). So I create it and chown.
STOP_TIMEOUT is too small, daemon is killed so unable to save anything.
Increased.
Please, integrate it to the new package build.
Leo 'costela' Antunes wrote:
Hi,
First off, problems and suggestions with Debian packages are better
discussed via a bugreport. Direct emails have a high chance of getting lost.
On 10/04/11 08:47, Roman Rybalko (devel) wrote:
PIDFILE didn't work because the daemon is started as another user, so
unable to write to the file. --make-pidfile doesn't change ownership
either (may be submit a feature request?). So I create it and chown.
Did you have any problems with --exec ? In this case I actually don't
see a problem in using it. I initially wanted to use --pidfile simply
out of habit, but in hindsight --exec doesn't seem to have caused any
problem in all these years.
Regardless, thanks for the heads-up regarding the "--pid-file" option
anyway. It's not even in the manpage.
--exec doesn't allow to launch another instances
STOP_TIMEOUT is too small, daemon is killed so unable to save anything.
Increased.
Good idea.
As for iosched, I don't see the point. Best-effort is the default
scheduler anyway, so it's not really much of a change.
And changing the nice value also seems a bit overkill. Have you really
seen performance issues while running it?
I'm open to adding it as an option in /etc/default/transmission-daemon,
but it honestly seems unnecessary in all but the most bizarre of cases.
Yes, I have performance issues, my samba stucks when transmission is
actively downloads/uploads something. So I need to decrease
transmission's nice & iosched priority.
As you can see, I decreased by default iosched to best-effort:7 (default
is best-effort:4) and nice to 5 (default is 0).
Actually I need to be able to set these values through
/etc/default/transmission-daemon.
--
WBR,
Roman Rybalko
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: transmission-daemon
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the transmission-daemon.
### END INIT INFO
NAME=transmission-daemon
DAEMON=/usr/bin/$NAME
USER=debian-transmission
PIDFILE=/var/run/$NAME.pid
STOP_TIMEOUT=30
CHDIR=/tmp
IOSCHED=best-effort:7
NICE=5
export PATH="${PATH:+$PATH:}/sbin"
[ -x $DAEMON ] || exit 0
[ -e /etc/default/$NAME ] && . /etc/default/$NAME
. /lib/lsb/init-functions
start_daemon () {
if [ $ENABLE_DAEMON != 1 ]; then
log_progress_msg "(disabled, see /etc/default/${NAME})"
else
touch $PIDFILE
chown $USER $PIDFILE
start-stop-daemon --start \
--chuid $USER --chdir $CHDIR \
--iosched $IOSCHED --nicelevel $NICE \
--startas $DAEMON --pidfile $PIDFILE -- --pid-file $PIDFILE $OPTIONS
fi
}
case "$1" in
start)
log_daemon_msg "Starting bittorrent daemon" "$NAME"
start_daemon
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
--pidfile $PIDFILE --retry $STOP_TIMEOUT \
--oknodo
log_end_msg 0
;;
reload)
log_daemon_msg "Reloading bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
--pidfile $PIDFILE \
--oknodo --signal 1
log_end_msg 0
;;
restart|force-reload)
log_daemon_msg "Restarting bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
--pidfile $PIDFILE --retry $STOP_TIMEOUT \
--oknodo
start_daemon
log_end_msg 0
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart}"
exit 2
;;
esac
exit 0
--- transmission-daemon.orig 2011-04-11 11:20:18.000000000 +0400
+++ transmission-daemon 2011-04-11 11:20:18.000000000 +0400
@@ -11,9 +11,11 @@
NAME=transmission-daemon
DAEMON=/usr/bin/$NAME
USER=debian-transmission
-# FIXME: no pidfile support; forks, so --make-pidfile doesn't work either
-#PIDFILE=/var/run/$NAME.pid
-STOP_TIMEOUT=3
+PIDFILE=/var/run/$NAME.pid
+STOP_TIMEOUT=30
+CHDIR=/tmp
+IOSCHED=best-effort:7
+NICE=5
export PATH="${PATH:+$PATH:}/sbin"
@@ -26,10 +28,13 @@
start_daemon () {
if [ $ENABLE_DAEMON != 1 ]; then
log_progress_msg "(disabled, see /etc/default/${NAME})"
- else
+ else
+ touch $PIDFILE
+ chown $USER $PIDFILE
start-stop-daemon --start \
- --chuid $USER \
- --exec $DAEMON -- $OPTIONS
+ --chuid $USER --chdir $CHDIR \
+ --iosched $IOSCHED --nicelevel $NICE \
+ --startas $DAEMON --pidfile $PIDFILE -- --pid-file $PIDFILE $OPTIONS
fi
}
@@ -42,21 +47,21 @@
stop)
log_daemon_msg "Stopping bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
- --exec $DAEMON --retry $STOP_TIMEOUT \
+ --pidfile $PIDFILE --retry $STOP_TIMEOUT \
--oknodo
log_end_msg 0
;;
reload)
log_daemon_msg "Reloading bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
- --exec $DAEMON \
+ --pidfile $PIDFILE \
--oknodo --signal 1
log_end_msg 0
;;
restart|force-reload)
log_daemon_msg "Restarting bittorrent daemon" "$NAME"
start-stop-daemon --stop --quiet \
- --exec $DAEMON --retry $STOP_TIMEOUT \
+ --pidfile $PIDFILE --retry $STOP_TIMEOUT \
--oknodo
start_daemon
log_end_msg 0