Help - Search - Members - Calendar
Full Version: httpd -> inet.d
Linuxhelp > Support > Technical Support
mmoor
I have this startup script in my init.d dir

The service starts without trouple and it runs, but if i go to stop it, the script hangs.. only way to stop it is kill or reboot.
Any hint ?

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd -DSSL}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache/run/httpd.pid}
lockfile=${LOCKFILE-/usr/local/apache/lock/httpd}
RETVAL=0

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL
DS2K3
Maybe it was just a typo - But I tihnk it is important to relaise that init.d and inet.d are two different things, that do two different jobs. Init controls runlevels, and the processes that are runnung, wherise inet (and xinet) are tcp/ip wrappers whcih allow programs to be wrapped up and used as servers.

I'm not really up-to-date with how Fedora init scripts work, but you might want to write your own script to handle starting/stopping Apache. Generallly the distribution-supplied ones are deswigned to cope with any scenario, when in relaity you maybe only want to start and stop the server with no special arguments. Below is the init script that I use on my Gentoo server:

CODE
#!/sbin/runscript

depend(){
need net
}

start(){
ebegin 'Starting Apache2'
export PHPRC="/usr/local/lib/php.ini"
/usr/local/apache2/bin/apachectl start
}

stop(){
ebegin 'Stopping Apache2'
/usr/local/apache2/bin/apachectl stop
}


Basically, instead of reinventing the wheel it just calls on Apache's own start/stop script to do the work for it. (The export PHPRC line just tells PHP which config file to read, and isn't strictly necessary). ebegin is a command to print the "starting..." messages, followed by an "ok" or "failed" depending on the message. You may need to try and combine the two things, since Gentoo provides a dedicated script interpreter esepcially for these kind of scripts, and by the look of it Fedora just uses standard bash ones.

D
mmoor
Heheh i tried already to write my own script.. omg, 2 days and failed.. no success.
nope its (/etc/rc.d/init.d)

hmm..
httpd=${HTTPD-/usr/local/apache/bin/httpd -DSSL}

i changed this into
httpd=${HTTPD-/usr/local/apache/bin/httpd -DSSL}
httpda=${HTTPD-/usr/local/apache/bin/httpd}

then under (stop)
killproc $httpda

this works kinda excpet the (SSL) http still runs smile.gif
dunno why..
DS2K3
I actually gave up on SSL myself and used an SSL wrapper program called "stunnel" to set up SSL access to my webserver. It isn't ideal, but it seems to work...

It also allowed me to serve a different site via HTTPS to HTTP
http://www.richardgomer.co.uk/
https://www.richardgomer.co.uk/

Do you have the apachectl script/program available? If so, it might be worth trying to call it in your script.

D
mmoor
yep have apachectl.. im just try to fumble in this init.d as few as i can.. managed it already that i blowed everything in the space smile.gif

the above script i got from the rpm of apache2.2 with the fedora distro, copied it out, then deinstalled apache then compiled apache 1.3 then copied the script back in and changed paths.
tryed to make one be myself, but ohh well after 2 days i gave up
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.