您的位置:首页 > 其它

UBUNTU SERVER 9.04 配置 RED5 开机启动

2009-10-29 17:35 381 查看
新建一个文件拷贝到/etc/initd.d/red5

文件内容:

Code
#!/bin/sh
#This is a red5 start/stop script on debian/ubuntu
#You will need to have screen installed
#red5 is started in its own screen, allowing debug
#for now, exept debug screen, there is no log

# Construct vars
#exe is the full path to the executable
name="Red5"
log_dir="/opt/red5/log"
workdir="/opt/red5/"
exe="./red5.sh"
#time=`echo $(date +%Y%m%d)_$(date +%H_%M_%S)`

# notify if no option is given
if [ $# -ne 1 ]; then
echo "Usage: $0 (start|stop|restart|status|debug) "
exit
fi

Start()
{
cd $tmp_dir
if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null; then
echo "$name is running, stop first to restart!"
else
#mv $log_dir/red5.log $log_dir/red5.log.$time
cd $workdir
$exe
echo "$name started"
fi
}

Stop()
{
if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null; then
echo "$name is runningStopping now"
ps -ef | grep "$exe" | grep -v grep | awk ' { print $2 } '| xargs kill > /dev/null
else
echo "$name not running"
fi
}

Status()
{
if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null ; then
echo "$name is running!"
else
echo "$name is not running!"
fi
}

Debug()
{
if ps -ef | grep SCREEN_$name | grep -v grep > /dev/null ; then
echo "$name is running!"
echo "You will now debug $name, to quit debugging press CTRL+A+D"
echo "DON'T USE CTRL+C, You will kill $name!"
echo "Press any key to continue"
read TA
/usr/bin/screen -r SCREEN_$name
else
echo "$name is not running!"
fi
}

# MAIN

case "$1" in
start)
Start
;;

stop)
Stop
;;

restart)
Stop
sleep 2
Start
;;

debug)
Debug
;;

status)
Status
;;

esac

exit 0

然后运行

cd /etc/init.d/
update-rc.d red5 defaults

可以通过

/etc/init.d/red5 start
启动服务

重启系统后red5服务随开机启动
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: