linux下设置RED5为系统服务
为什么要设置成系统服务呢?因为我在某台服务器安装的red5不知道什么原因,在rc.local那里不能随系统启动,ln到rc.X也不行.想尽办法,只好设置成系统服务才能解决问题...
修改red5.sh
#!/bin/sh
#
# Startup script for Red5 flash streaming server
#
# chkconfig: 345 81 81
# description: RED5 by java
#
# processname: java (unfortunately)
# pidfile: /var/run/red5.pid
# config: /etc/red5.conf
# Source function library.
. /etc/rc.d/init.d/functions
PID_FILE=/var/run/red5.pid
PID=`ps ax |grep java|grep red5|awk '{print $1;}'`
RETVAL=0
start() {
echo -n $"Starting $DESCR: "
# daemon java $OPTIONS > /dev/null 2>&1 &
export ANT_HOME=/opt/apache-ant-1.6.5
export JAVA_HOME=/opt/jdk1.5.0_06
export JAVA_VERSION=1.5
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin
exec $JAVA_HOME/bin/java -Djava.security.manager -Djava.security.policy=/opt/red5/conf/red5.policy -cp /opt/red5/red5.jar:conf:/opt/red5/conf org.red5.server.Standalone > /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
注意:前面注释那些内容是必须的.可以修改.
放到/etc/init.d/
mv /opt/red5/red5.sh /etc/init.d/red5
可以直接启动或者停止服务 service red5 start|stop
设置成启动服务chkconfig red5 on