UBUNTU SERVER 9.04 配置 RED5 开机启动

本文介绍了如何在Debian/Ubuntu系统中部署红5服务,包括创建启动脚本、配置环境变量、实现服务的启动、停止、重启和状态检查,并确保服务随系统启动。
新建一个文件拷贝到/etc/initd.d/red5
文件内容:
#!/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服务随开机启动

转载于:https://my.oschina.net/waterbear/blog/149765

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值