I had some problems with THTTPD_DOCROOT on an autofs managed partition on startup and the need for many instances of thttpd. It work good for me since many days/reboots, so I wont to share my patch. Reproducible: Always Steps to Reproduce: Reproduce of autofs issue: 1. Create a autofs managed partition. 2. Set THTTPD_DOCROOT to it and copy content. 3. Reboot the system. Actual Results: The thttpd instance fail to start. Expected Results: The thttpd instance start. The problem is that autofs start after thttpd, and so the THTTPD_DOCROOT is not existent at starttime of thttpd. Add netmount to the depend function start thttpd after autofs (or nfs).
Created attachment 317200 [details] the new conf.d config maybe a better description of the multi-instance foo.
Created attachment 317202 [details] enhanced init-script
Comment on attachment 317200 [details] the new conf.d config --- files/thttpd.confd 2012-04-05 16:50:05.000000000 +0200 +++ - 2012-07-05 16:38:57.066438496 +0200 @@ -1,6 +1,5 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later -# $Header: /var/cvsroot/gentoo-x86/www-servers/thttpd/files/thttpd.confd,v 1.2 2012/04/04 15:05:36 blueness Exp $ ## Config file for /etc/init.d/thttpd @@ -11,12 +10,21 @@ ## There are 2 ways to configure thttpd: ## 1) specify all params on the cmd-line ## 2) use a config-file (and start with "-C <conf-file>") -## Note: 1) and 2) can be mixed. + +## For additional thttpd instances, run: +# ln -s /etc/init.d/thttpd /etc/init.d/thttpd.$NAME +# cp /etc/conf.d/thttpd /etc/conf.d/thttpd.$NAME + +## Note: 1) and 2) can be mixed but +## the init-script set PID (option -i) to +## /var/run/thttpd.$NAME.run +## and logfile (option -l) to +## /var/log/thttpd.$NAME.log ## ## We choose 1) here -- if you have a more complicated setup read ## thttpd(8) for details on 2). -THTTPD_OPTS="-p 8080 -u thttpd -r -i /var/run/thttpd.pid -l /var/log/thttpd.log" +THTTPD_OPTS="-p 8080 -u thttpd -r -i" ## For a more complex setup (e.g. cgi-support) use an external configfile: ## comment the THTTPD_OPTS line above und use the one below.
Comment on attachment 317202 [details] enhanced init-script --- files/thttpd.init 2012-03-24 03:59:02.000000000 +0100 +++ - 2012-07-05 16:39:29.771442667 +0200 @@ -1,26 +1,34 @@ #!/sbin/runscript # Copyright 1999-2012 Gentoo Foundation -# Distributed under the terms of the GNU General Public License, v2 or later -# $Header: /var/cvsroot/gentoo-x86/www-servers/thttpd/files/thttpd.init,v 1.1 2012/03/24 02:59:02 blueness Exp $ +# Distributed under the terms of the GNU General Public License, v3 or later depend() { need net + use dns logger netmount + after sshd } -start() { - ebegin "Starting thttpd" +checkconfig() { if [ ! -d "$THTTPD_DOCROOT" ]; then - eend 1 "THTTPD_DOCROOT not set correctly in /etc/conf.d/thttpd" - exit 1 + eend 1 "THTTPD_DOCROOT not set correctly in /etc/conf.d/${SVCNAME}" fi +} + +start() { + ebegin "Starting ${SVCNAME}" + + checkconfig || return 1 + start-stop-daemon --quiet --start --exec /usr/sbin/thttpd \ - --pidfile /var/run/thttpd.pid --chdir "$THTTPD_DOCROOT" -- \ + --pidfile /var/run/${SVCNAME}.pid --chdir "$THTTPD_DOCROOT" -- \ + -i /var/run/${SVCNAME}.pid \ + -l /var/log/${SVCNAME}.log \ ${THTTPD_OPTS} eend $? } stop() { - ebegin "Stopping thttpd" - start-stop-daemon --quiet --stop --pidfile /var/run/thttpd.pid + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --quiet --stop --pidfile /var/run/${SVCNAME}.pid eend $? }
(In reply to comment #3) > Comment on attachment 317200 [details] > the new conf.d config I have found a bug in the file i have posted: > --- files/thttpd.confd 2012-04-05 16:50:05.000000000 +0200 This is wrong: > +THTTPD_OPTS="-p 8080 -u thttpd -r -i" This is right: +THTTPD_OPTS="-p 8080 -u thttpd -r" Sorry for inconvenience. :-/
Created attachment 317338 [details] Remove the unneeded -i option form config file. The new init script do not need it.
Thank you very much for this! The changes are in the tree with thttpd-2.26.4. Please test and if there's any problem, reopen this bug.