So I have red5 streaming server installed and can get it to launch and stay launched when closing ssh terminal window using the following init.d script code:
#!/bin/bash
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5
# Created By: Sohail Riaz (sohaileo@gmail.com)
PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case "$1" in
start)
echo -n $"Starting $PROG: "
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG
fi
[ $RETVAL -eq 0 ] && success $"$PROG startup" || failure $"$PROG startup"
echo
;;
stop)
echo -n $"Shutting down $PROG: "
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVALSo I can just type 'red5 start', 'red5 status' and 'red5 stop'.
Now I renamed the red5 folder to red5bak and have been testing a new updated version in a new 'red5' folder which also uses a red5.sh file to launch. I can launch this manually no problem and works as intended however when launched with the above commands and code it says started 'OK' but appears not to and when using 'status' command I get the error red5 dead but pid file exists.
I tried deleting the pid red5 files in var/run and lock folders and restarting server but still get the same issue.
If I delete the newer red5 folder and rename the old folder back then the script works again so how can I get it to work for the newer version/files?
Any help would be appreciated,
Thanks.