Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 424826 - www-servers/thttpd-2.26.2 - Multi-instance enhancement and stable start with autofs of the init-script
Summary: www-servers/thttpd-2.26.2 - Multi-instance enhancement and stable start with...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2012-07-05 03:11 UTC by Kola Bernard
Modified: 2012-07-13 14:12 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
the new conf.d config (thttpd.confd,1.24 KB, text/plain)
2012-07-05 03:17 UTC, Kola Bernard
Details
enhanced init-script (thttpd.init,734 bytes, text/plain)
2012-07-05 03:18 UTC, Kola Bernard
Details
Remove the unneeded -i option form config file. The new init script do not need it. (thttpd.confd,1.24 KB, text/plain)
2012-07-05 18:39 UTC, Kola Bernard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kola Bernard 2012-07-05 03:11:10 UTC
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).
Comment 1 Kola Bernard 2012-07-05 03:17:04 UTC
Created attachment 317200 [details]
the new conf.d config

maybe a better description of the multi-instance foo.
Comment 2 Kola Bernard 2012-07-05 03:18:26 UTC
Created attachment 317202 [details]
enhanced init-script
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2012-07-05 14:39:06 UTC
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 4 Jeroen Roovers (RETIRED) gentoo-dev 2012-07-05 14:39:39 UTC
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 $?
 }
Comment 5 Kola Bernard 2012-07-05 18:36:17 UTC
(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. :-/
Comment 6 Kola Bernard 2012-07-05 18:39:31 UTC
Created attachment 317338 [details]
Remove the unneeded -i option form config file. The new init script do not need it.
Comment 7 Anthony Basile gentoo-dev 2012-07-13 14:12:40 UTC
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.