Linux系统设置RED5为系统服务

2019-06-19 20:02栏目:技术创新

注意:前面注释那些内容是必须的.可以修。

放到/etc/init.d/

mv /opt/red5/red5.sh /etc/init.d/red5

可以直接启动或者停止服务 service red5 start|stop

设置成启动服务chkconfig red5 on

#!/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
#该片段来自于http://outofmemory.cn

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:Linux系统设置RED5为系统服务