Red5 start/stop init script on CentOS / RedHat Linux
By Ruben on Jun 9, 2006 | In Red5 flash server | 4 feedbacks »
The v0.41 release of Red5 contains a start/stop init script (/etc/init.d/red5 start) for Debian.
I'am running CentOS 4.x a 100% free and compatible alternative to RedHat ES.
There problems with the init script became clear.
Debian uses the function "start-stop-daemon()" to fire up services. As far as I know CentOS still uses "daemon()" to start services. Unfortunately, function daemon() is limited in its control....
The file attached contains my first attempt of a start/stop init script for CentOS. It's far from perfect but it's working.
Comments are welcome!
PS In the script I've added a RUNTIME user to avoid running as ROOT.
#!/bin/bash
#
# Startup script for Red5 flash streaming server
# Author: Ruben Waitz - www.amtex.nl
# Version 0.9 - 06/09/2006
#
# processname: java (unfortunately)
# pidfile: /var/run/red5.pid
# config: /etc/red5.conf
# Source function library.
. /etc/rc.d/init.d/functions
RED5_HOME=/opt/red5/
RUNTIME_USER=nobody
JAVACMD=/usr/java/jdk1.5.0_06/bin/java
OPTIONS="-cp ${RED5_HOME}red5.jar:${RED5_HOME}conf:$CLASSPATH org.red5.server.Standalone"
DESCR="Red5 flash streaming server"
PID_FILE=/var/run/red5.pid
PID=`ps ax |grep java|grep red5|awk '{print $1;}'`
RETVAL=0
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
# Read config file if it is present.
if [ -r /etc/red5.conf ]
then
. /etc/red5.conf
fi
start() {
echo -n $"Starting $DESCR: "
# daemon $JAVACMD $OPTIONS > /dev/null 2>&1 &
su -p -s /bin/sh $RUNTIME_USER -c "\"$JAVACMD\" $OPTIONS" > /dev/null 2>&1 &
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/red5 && echo $!>$PID_FILE && echo_success
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $DESCR: "
#killproc $PID_FILE
[[ $PID != "" ]] && success && kill $PID || failure
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/red5 $PID_FILE
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $DESCR {start|stop|restart"
exit 1
esac
exit $RETVAL
3 comments

Comments are closed for this post.
« How to make ColdFusion 7 unresponsive in just a sec |