[CentOS] Init.d script troubleshooting.

Wed Nov 10 01:03:28 UTC 2010
Don Krause <dkrause at optivus.com>

I got a strange problem with init.d scripts on a fully updated (as of today) fresh install of 5.5 x64.

I've written a script, /etc/init.d/Fast that starts a fairly large and slow commercial application, by calling that applications control binary to do the actual work.

I "registered" the script, via chkconfig --add Fast, and the symlinks are in the expected places.

[root at rpmbuilder etc]# ls /etc/rc*/*Fast
/etc/rc0.d/K10Fast  /etc/rc4.d/S90Fast
/etc/rc1.d/K10Fast  /etc/rc5.d/S90Fast
/etc/rc2.d/K10Fast  /etc/rc6.d/K10Fast
/etc/rc3.d/S90Fast

[root at rpmbuilder etc]# ls -la init.d/Fast
-rwxr-xr-x 1 root root 2691 Nov  9 16:49 init.d/Fast
[root at rpmbuilder etc]# 

Testing the script, both via "/etc/init.d/Fast start" and "service Fast start" works, and it fully works for the implemented "start","stop","status" commands.

"/etc/rc0.d/K10Fast stop" works as expected. (as does /etc/rc1,2,6 etc..)

The script contains full paths to everything.

At boot, the script functions as expected.

My problem is that at reboot, via shutdown -r or shutdown -h the script does NOT get called, so naturally the system doesn't get to clean up after itself, then it fails to startup correctly next boot.

The startup and shutdown of this application is slow, 2+ minutes. I know it doesn't work at reboot or halt because the host goes down fast, and the system is littered with left over pid files and such that prevents a clear restart of the Fast process.

I've placed echo commands in the script, both in the stop() function to log the date/time to a file when it's called, and in the head of the script itself, just to see if it gets called at all during shutdown. 

As far as I can tell, the script does NOT get called at shutdown/reboot time. At all.

I'm just confused, this ain't supposed to be this hard... Is there some way to debug init?

Suggestions?

Thanks

<-- /etc/init.f/Fast -->
#!/bin/bash
#
# Startup script for Fast
#
# chkconfig: 345 90 10
# description: Fast Search Engine
# processname: nctrl
echo "************************* In Fast ****************************"
# Source function library
. /etc/init.d/functions

RETVAL=0

FASTSEARCH=/opt/Opti/9.1/Fast/fast
BIN=${FASTSEARCH}/bin
LIBPATH=${FASTSEARCH}/lib
SHLIB=${FASTSEARCH}/lib
LD_LIBRARY_PATH=${FASTSEARCH}/lib
PYTHONPATH=${FASTSEARCH}/lib/python2.3/lib-dynload

export FASTSEARCH LIBPATH SHLIB LD_LIBRARY_PATH PYTHONPATH

start() {
	if [ -f ${BIN}/nctrl ]; then
		cd ${BIN}
		echo -n $"Starting Fast "
		su fastadmin -c "./nctrl start"
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/fast
		echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping Fast "
	cd ${BIN}
	su fastadmin -c "./nctrl stop"
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/fast
	echo
	return $RETVAL
}

status() {
	cd ${BIN}
	su fastadmin -c "./nctrl status"
}

restart() {
	stop
	start
}

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
restart)
	restart
	;;
killlock)
	if [ -f /var/lock/subsys/fast ]; then
		rm -f /var/lock/subsys/fast
	fi
	;;
status)
	status
	;;
*)
	echo $"Usage: $0 {start|stop|restart|killlock|status}"
	exit 1
esac

exit $RETVAL


--
Don Krause                                                                   






-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4657 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20101109/17f17411/attachment-0004.p7s>