From 05e22e9530709a5cac7d2a45f9e0312956beef1e Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 7 Apr 2014 15:26:21 +0800 Subject: [PATCH] fix script run/build/stop bug --- trunk/auto/options.sh | 18 +- trunk/conf/demo.19350.conf | 2 +- trunk/conf/demo.conf | 2 +- trunk/etc/init.d/srs-demo | 184 ++++++++++++++++++++ trunk/etc/init.d/srs-demo-19350 | 184 ++++++++++++++++++++ trunk/scripts/_ffmpeg.demo.sh | 7 - trunk/scripts/_ffmpeg.players.sh | 7 - trunk/scripts/_step.build.sh | 10 -- trunk/scripts/_step.start.api.server.sh | 12 -- trunk/scripts/_step.start.ffmpeg.demo.sh | 12 -- trunk/scripts/_step.start.ffmpeg.players.sh | 12 -- trunk/scripts/_step.start.nginx.sh | 14 -- trunk/scripts/_step.start.srs.19350.sh | 12 -- trunk/scripts/_step.start.srs.sh | 12 -- trunk/scripts/build.sh | 4 +- trunk/scripts/run.sh | 26 +-- trunk/scripts/stop.sh | 34 +--- 17 files changed, 394 insertions(+), 158 deletions(-) create mode 100755 trunk/etc/init.d/srs-demo create mode 100755 trunk/etc/init.d/srs-demo-19350 delete mode 100755 trunk/scripts/_ffmpeg.demo.sh delete mode 100755 trunk/scripts/_ffmpeg.players.sh delete mode 100755 trunk/scripts/_step.build.sh delete mode 100755 trunk/scripts/_step.start.api.server.sh delete mode 100755 trunk/scripts/_step.start.ffmpeg.demo.sh delete mode 100755 trunk/scripts/_step.start.ffmpeg.players.sh delete mode 100755 trunk/scripts/_step.start.nginx.sh delete mode 100755 trunk/scripts/_step.start.srs.19350.sh delete mode 100755 trunk/scripts/_step.start.srs.sh diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 7399d1ab5..04b98530d 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -131,6 +131,15 @@ done ##################################################################################### # apply the default value when user donot specified. ##################################################################################### +# if http-xxxx specified, open the SRS_HTTP_PARSER +if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi +if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi +if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi + +# if transcode specified, try ffmpeg if possible. +if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi +if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi + # if arm specified, set some default to disabled. if [ $SRS_ARM_UBUNTU12 = YES ]; then if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi @@ -231,15 +240,6 @@ if [ $SRS_PI = YES ]; then SRS_STATIC=YES fi -# if http-xxxx specified, open the SRS_HTTP_PARSER -if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi -if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi -if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi - -# if transcode specified, try ffmpeg if possible. -if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi -if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi - # parse the jobs for make if [[ "" -eq SRS_JOBS ]]; then export SRS_JOBS="--jobs" diff --git a/trunk/conf/demo.19350.conf b/trunk/conf/demo.19350.conf index ab5422ca9..91fa6981f 100644 --- a/trunk/conf/demo.19350.conf +++ b/trunk/conf/demo.19350.conf @@ -5,7 +5,7 @@ listen 19350; daemon on; srs_log_tank file; -srs_log_file ./objs/demo.19350.log; +srs_log_file ./objs/srs.demo.19350.log; pid ./objs/srs.demo.19350.pid; vhost __defaultVhost__ { diff --git a/trunk/conf/demo.conf b/trunk/conf/demo.conf index c9b7ddaa7..0ef397807 100644 --- a/trunk/conf/demo.conf +++ b/trunk/conf/demo.conf @@ -5,7 +5,7 @@ listen 1935; daemon on; srs_log_tank file; -srs_log_file ./objs/demo.log; +srs_log_file ./objs/srs.demo.log; pid ./objs/srs.demo.pid; chunk_size 60000; diff --git a/trunk/etc/init.d/srs-demo b/trunk/etc/init.d/srs-demo new file mode 100755 index 000000000..e7e2bd5eb --- /dev/null +++ b/trunk/etc/init.d/srs-demo @@ -0,0 +1,184 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: simple-rtmp-server(srs) +# RequiRED-Start: $all +# RequiRED-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: simple-rtmp-server(srs) +# Description: https://github.com/winlinvip/simple-rtmp-server +### END INIT INFO + +# the config of ROOT, user must modify it when start srs from other directory, +# it's ok to use the script by command ./etc/init.d/simple-rtmp-server +ROOT="./" +APP="./objs/srs" +CONFIG="./conf/demo.conf" +DEFAULT_PID_FILE='./objs/srs.demo.pid' +DEFAULT_LOG_FILE='./objs/srs.demo.log' + +######################################################################## +# utility functions +######################################################################## +RED="\\e[31m" +GREEN="\\e[32m" +YELLOW="\\e[33m" +BLACK="\\e[0m" +POS="\\e[60G" + +ok_msg() { + echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]" +} + +failed_msg() { + echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]" +} + +# load process info of srs +# @set variable $srs_pid to the process id in srs.pid file. +# @return 0, if process exists; otherwise: +# 1, for pid file not exists. +# 2, for get proecess info by pid failed. +# @set variable $error_msg if error. +# @set variable $pid_file to pid file. +load_process_info() { + # get pid file + pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'` + if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi + # get abs path + pid_dir=`dirname $pid_file` + pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file` + + srs_pid=`cat $pid_file 2>/dev/null` + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi + + ps -p ${srs_pid} >/dev/null 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi + + return 0; +} + +start() { + # if exists, exit. + load_process_info + if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi + + # not exists, start server + ok_msg "Starting SRS..." + + # get log file + log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'` + if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi + # get abs path + log_dir=`dirname $log_file` + log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file` + + # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" + if [[ -z $log_file ]]; then + (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) + else + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) + fi + + # check again after start server + for ((i = 0; i < 5; i++)); do + # sleep a little while, for srs may start then crash. + sleep 0.1 + load_process_info + ret=$?; if [[ 0 -ne $ret ]]; then + failed_msg "SRS start failed"; + failed_msg "see $log_file"; + return $ret; + fi + done + + # check whether started. + load_process_info + ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi + + failed_msg "SRS not started" + return $ret +} + +stop() { + # not start, exit + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi + + ok_msg "Stopping SRS(pid ${srs_pid})..." + + # process exists, kill util stop + for((;;)); do + load_process_info + if [[ 0 -eq $? ]]; then + kill -s SIGTERM ${srs_pid} 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi + sleep 0.1 + else + ok_msg "SRS stopped" + break; + fi + done + + sleep 0.1 + return 0 +} + +# get the status of srs process +# @return 0 if srs is running; otherwise, 1 for stopped. +status() { + load_process_info + ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi + + echo "SRS is stopped, $error_msg" + return 1 +} + +reload() { + # not start, exit + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi + + ok_msg "Reload SRS(pid ${srs_pid})..." + + # process exists, reload it + kill -s SIGHUP ${srs_pid} 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi + + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi + + ok_msg "SRS reloaded" + return 0 +} + +menu() { + case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + reload) + reload + ;; + *) + echo "Usage: $0 {start|stop|status|restart|reload}" + return 1 + ;; + esac +} + +menu $1 + +code=$? +exit ${code} diff --git a/trunk/etc/init.d/srs-demo-19350 b/trunk/etc/init.d/srs-demo-19350 new file mode 100755 index 000000000..704b89bdc --- /dev/null +++ b/trunk/etc/init.d/srs-demo-19350 @@ -0,0 +1,184 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: simple-rtmp-server(srs) +# RequiRED-Start: $all +# RequiRED-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: simple-rtmp-server(srs) +# Description: https://github.com/winlinvip/simple-rtmp-server +### END INIT INFO + +# the config of ROOT, user must modify it when start srs from other directory, +# it's ok to use the script by command ./etc/init.d/simple-rtmp-server +ROOT="./" +APP="./objs/srs" +CONFIG="./conf/demo.19350.conf" +DEFAULT_PID_FILE='./objs/srs.demo.19350.pid' +DEFAULT_LOG_FILE='./objs/srs.demo.19350.log' + +######################################################################## +# utility functions +######################################################################## +RED="\\e[31m" +GREEN="\\e[32m" +YELLOW="\\e[33m" +BLACK="\\e[0m" +POS="\\e[60G" + +ok_msg() { + echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]" +} + +failed_msg() { + echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]" +} + +# load process info of srs +# @set variable $srs_pid to the process id in srs.pid file. +# @return 0, if process exists; otherwise: +# 1, for pid file not exists. +# 2, for get proecess info by pid failed. +# @set variable $error_msg if error. +# @set variable $pid_file to pid file. +load_process_info() { + # get pid file + pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'` + if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi + # get abs path + pid_dir=`dirname $pid_file` + pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file` + + srs_pid=`cat $pid_file 2>/dev/null` + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi + + ps -p ${srs_pid} >/dev/null 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi + + return 0; +} + +start() { + # if exists, exit. + load_process_info + if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi + + # not exists, start server + ok_msg "Starting SRS..." + + # get log file + log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'` + if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi + # get abs path + log_dir=`dirname $log_file` + log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file` + + # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" + if [[ -z $log_file ]]; then + (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) + else + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) + fi + + # check again after start server + for ((i = 0; i < 5; i++)); do + # sleep a little while, for srs may start then crash. + sleep 0.1 + load_process_info + ret=$?; if [[ 0 -ne $ret ]]; then + failed_msg "SRS start failed"; + failed_msg "see $log_file"; + return $ret; + fi + done + + # check whether started. + load_process_info + ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi + + failed_msg "SRS not started" + return $ret +} + +stop() { + # not start, exit + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi + + ok_msg "Stopping SRS(pid ${srs_pid})..." + + # process exists, kill util stop + for((;;)); do + load_process_info + if [[ 0 -eq $? ]]; then + kill -s SIGTERM ${srs_pid} 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi + sleep 0.1 + else + ok_msg "SRS stopped" + break; + fi + done + + sleep 0.1 + return 0 +} + +# get the status of srs process +# @return 0 if srs is running; otherwise, 1 for stopped. +status() { + load_process_info + ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi + + echo "SRS is stopped, $error_msg" + return 1 +} + +reload() { + # not start, exit + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi + + ok_msg "Reload SRS(pid ${srs_pid})..." + + # process exists, reload it + kill -s SIGHUP ${srs_pid} 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi + + load_process_info + if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi + + ok_msg "SRS reloaded" + return 0 +} + +menu() { + case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + reload) + reload + ;; + *) + echo "Usage: $0 {start|stop|status|restart|reload}" + return 1 + ;; + esac +} + +menu $1 + +code=$? +exit ${code} diff --git a/trunk/scripts/_ffmpeg.demo.sh b/trunk/scripts/_ffmpeg.demo.sh deleted file mode 100755 index 0c1d94c49..000000000 --- a/trunk/scripts/_ffmpeg.demo.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \ - -vcodec copy -acodec copy \ - -f flv -y rtmp://127.0.0.1/live?vhost=demo.srs.com/livestream; \ - sleep 1; \ -done diff --git a/trunk/scripts/_ffmpeg.players.sh b/trunk/scripts/_ffmpeg.players.sh deleted file mode 100755 index 6d18c5933..000000000 --- a/trunk/scripts/_ffmpeg.players.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -for((;;)); do \ - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \ - -vcodec copy -acodec copy \ - -f flv -y rtmp://127.0.0.1/live?vhost=players/demo; \ - sleep 1; \ -done diff --git a/trunk/scripts/_step.build.sh b/trunk/scripts/_step.build.sh deleted file mode 100755 index 6a06ce19e..000000000 --- a/trunk/scripts/_step.build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -echo "编译SRS" -./configure --with-ssl --with-hls --with-http-server --with-ffmpeg --with-transcode --with-http-callback && make -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi - -echo "编译SRS成功" -exit 0 diff --git a/trunk/scripts/_step.start.api.server.sh b/trunk/scripts/_step.start.api.server.sh deleted file mode 100755 index 2179159aa..000000000 --- a/trunk/scripts/_step.start.api.server.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="nohup python ./research/api-server/server.py 8085 >./objs/api-server.log 2>&1 &" -echo "启动API服务器:$cmd" -pids=`ps aux|grep python|grep research|grep "api-server"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done -nohup python ./research/api-server/server.py 8085 >./objs/api-server.log 2>&1 & -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi - -echo "启动API服务器成功" -exit 0 diff --git a/trunk/scripts/_step.start.ffmpeg.demo.sh b/trunk/scripts/_step.start.ffmpeg.demo.sh deleted file mode 100755 index c8395281c..000000000 --- a/trunk/scripts/_step.start.ffmpeg.demo.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="nohup bash ./scripts/_ffmpeg.demo.sh >./objs/ffmpeg-demo.log 2>&1 &" -echo "启动FFMPEG推送demo流(播放器上12路演示):$cmd" -pids=`ps aux|grep scripts|grep "/_ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done -nohup bash ./scripts/_ffmpeg.demo.sh >./objs/ffmpeg-demo.log 2>&1 & -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送demo流(播放器上12路演示)失败"; exit $ret; fi - -echo "启动FFMPEG推送demo流(播放器上12路演示)成功" -exit 0 diff --git a/trunk/scripts/_step.start.ffmpeg.players.sh b/trunk/scripts/_step.start.ffmpeg.players.sh deleted file mode 100755 index 900274b9e..000000000 --- a/trunk/scripts/_step.start.ffmpeg.players.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="nohup bash ./scripts/_ffmpeg.players.sh >./objs/ffmpeg-players.log 2>&1 &" -echo "启动FFMPEG推送players流(播放器上演示用):$cmd" -pids=`ps aux|grep scripts|grep "/_ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done -nohup bash ./scripts/_ffmpeg.players.sh >./objs/ffmpeg-players.log 2>&1 & -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送players流(播放器上演示用)失败"; exit $ret; fi - -echo "启动FFMPEG推送players流(播放器上演示用)成功" -exit 0 diff --git a/trunk/scripts/_step.start.nginx.sh b/trunk/scripts/_step.start.nginx.sh deleted file mode 100755 index 8873f093c..000000000 --- a/trunk/scripts/_step.start.nginx.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="sudo ./objs/nginx/sbin/nginx" -echo "启动NGINX(HLS服务):$cmd" -if [[ -f ./objs/nginx/logs/nginx.pid ]]; then - pids=`cat ./objs/nginx/logs/nginx.pid`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGTERM $pid; done -fi -sudo ./objs/nginx/sbin/nginx -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动NGINX(HLS服务)失败"; exit $ret; fi - -echo "启动NGINX(HLS服务)成功" -exit 0 diff --git a/trunk/scripts/_step.start.srs.19350.sh b/trunk/scripts/_step.start.srs.19350.sh deleted file mode 100755 index 04f3ea5ea..000000000 --- a/trunk/scripts/_step.start.srs.19350.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="./objs/srs -c conf/demo.19350.conf" -echo "启动SRS转发服务器:$cmd" -pids=`cat ./objs/srs.demo.19350.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done -./objs/srs -c conf/demo.19350.conf -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi - -echo "启动SRS转发服务器成功" -exit 0 diff --git a/trunk/scripts/_step.start.srs.sh b/trunk/scripts/_step.start.srs.sh deleted file mode 100755 index 9cc79f842..000000000 --- a/trunk/scripts/_step.start.srs.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -cmd="./objs/srs -c conf/demo.conf" -echo "启动SRS服务器:$cmd" -pids=`cat ./objs/srs.demo.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done -./objs/srs -c conf/demo.conf -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi - -echo "启动SRS服务器成功" -exit 0 diff --git a/trunk/scripts/build.sh b/trunk/scripts/build.sh index 695442d84..fc609725c 100755 --- a/trunk/scripts/build.sh +++ b/trunk/scripts/build.sh @@ -3,6 +3,8 @@ src_dir='src' if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi # step 1: build srs -bash scripts/_step.build.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi +echo "编译SRS" +./configure --with-ssl --with-hls --with-http-server --with-ingest --with-transcode --with-http-callback && make +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi echo "编译SRS成功" diff --git a/trunk/scripts/run.sh b/trunk/scripts/run.sh index 4e23868af..98790c27c 100755 --- a/trunk/scripts/run.sh +++ b/trunk/scripts/run.sh @@ -8,29 +8,15 @@ GREEN="\\e[32m" YELLOW="\\e[33m" BLACK="\\e[0m" -# step 1: build srs -#bash scripts/_step.build.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi +./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi +echo "启动SRS服务器成功" -# step 2: start srs -bash scripts/_step.start.srs.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi +./etc/init.d/srs-demo-19350 restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi +echo "启动SRS转发服务器成功" -# step 3(optinal): start srs listen at 19350 to forward to -bash scripts/_step.start.srs.19350.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi +./etc/init.d/srs-api restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi +echo "启动API服务器成功" -# REMOVED: for we use srs-http-server instead. -# step 4(optinal): start nginx for HLS -#bash scripts/_step.start.nginx.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi - -# step 5(optinal): start http hooks for srs callback -bash scripts/_step.start.api.server.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi - -# step 6: publish demo live stream -#bash scripts/_step.start.ffmpeg.demo.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi - -# step 7: publish players live stream -#bash scripts/_step.start.ffmpeg.players.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi - -# step 8: add server ip to client hosts as demo. ip=`ifconfig|grep "inet"|grep "addr"|grep "Mask"|grep -v "127.0.0.1"|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'` port=8085 cat<