The init script in preload invokes start-stop-daemon to start the preload daemon, with the option to create a pid file, then attempts to ionice the pid in the pid file. This is wrong, as the pid file may not be available after start-stop-daemon returns. On my x86 system startup is randomly reported to fail because the pid file does not exist when ionice is called; the daemon is however started and the pid file eventually created. Solution is to start the daemon with ionice. The pid of the daemon will be the same the pid of the ionice process, because it uses fork(), so this is correct. Reproducible: Sometimes Steps to Reproduce:
Created attachment 214782 [details, diff] patch for preload init script This patch solves the problem by starting preload with ionice.
Created attachment 214785 [details, diff] patch for preload init script expand options to arguments...
Thanks for the patch, looks like a good solution. Assigning to maintainer.
I no longer use this application and have dropped maintainer-ship.
With your patch, preload no longer starts :-(, I simply get: * Starting preload ... [ !! ] The problem is that I don't know where it is failing, I simply checked that, if I force it to run without ionice (I mean, I make it EXEC="/usr/sbin/preload" and ARGS=() ) it succeeds
I cannot reproduce this. You may be giving invalid options to ionice. Try running the resulting command by hand.
I have added the following to init.d to test: echo ${PIDFILE} echo "$EXEC" echo "${ARGS[@]}" echo ${PRELOAD_LOGFILE:-/var/log/preload.log} echo ${PRELOAD_VERBOSITY:-1} echo ${PRELOAD_NICE:-15} echo ${PRELOAD_STATEFILE:-""} echo ${PRELOAD_OPTS} Resulting in: * Starting preload ... /var/run/preload.pid /usr/bin/ionice -c3 /usr/sbin/preload /var/log/preload.log 1 15 /var/lib/preload/preload.state [ !! ] But it seems to run when manually running: # start-stop-daemon --start --quiet --background --make-pidfile --pidfile /var/run/preload.pid --exec /usr/bin/ionice -- -c3 /usr/sbin/preload -l /var/log/preload.log -V 1 -n 15 -s /var/lib/preload/preload.state -f # echo $? 0 :-/
Created attachment 229317 [details] init script Looks like something is having problems with arrays. Try this one.
Sadly still the same :-( Are you using baselayout-2/openrc ? I am still using baselayout-1 (that runs scripts using bash instead of dash)
The more correct approach is to start s-s-d through ionice (the priority descends to the child process). I've attached a fixed init.d script to bug #310511.
+*preload-0.6.4-r2 (07 Sep 2010) + + 07 Sep 2010; Pacho Ramos <pacho@gentoo.org> +preload-0.6.4-r2.ebuild, + +files/preload-0.6.4.init.in-r1: + Revision bump to fix race condition (bug #299140 by Ambroz Bizjak) and + make it POSIX compliant (bug #310511 by Michał Górny), thanks a lot to + Michał for providing the new init.d script.