歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux服務器

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 {GetProperty(Content)};}'`
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 "{GetProperty(Content)}" 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

 

Copyright © Linux教程網 All Rights Reserved