winlin

fix script run/build/stop bug

@@ -131,6 +131,15 @@ done @@ -131,6 +131,15 @@ done
131 ##################################################################################### 131 #####################################################################################
132 # apply the default value when user donot specified. 132 # apply the default value when user donot specified.
133 ##################################################################################### 133 #####################################################################################
  134 +# if http-xxxx specified, open the SRS_HTTP_PARSER
  135 +if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi
  136 +if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi
  137 +if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi
  138 +
  139 +# if transcode specified, try ffmpeg if possible.
  140 +if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi
  141 +if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi
  142 +
134 # if arm specified, set some default to disabled. 143 # if arm specified, set some default to disabled.
135 if [ $SRS_ARM_UBUNTU12 = YES ]; then 144 if [ $SRS_ARM_UBUNTU12 = YES ]; then
136 if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi 145 if [ $SRS_HLS = RESERVED ]; then SRS_HLS=YES; fi
@@ -231,15 +240,6 @@ if [ $SRS_PI = YES ]; then @@ -231,15 +240,6 @@ if [ $SRS_PI = YES ]; then
231 SRS_STATIC=YES 240 SRS_STATIC=YES
232 fi 241 fi
233 242
234 -# if http-xxxx specified, open the SRS_HTTP_PARSER  
235 -if [ $SRS_HTTP_CALLBACK = YES ]; then SRS_HTTP_PARSER=YES; fi  
236 -if [ $SRS_HTTP_SERVER = YES ]; then SRS_HTTP_PARSER=YES; fi  
237 -if [ $SRS_HTTP_API = YES ]; then SRS_HTTP_PARSER=YES; fi  
238 -  
239 -# if transcode specified, try ffmpeg if possible.  
240 -if [ $SRS_TRANSCODE = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi  
241 -if [ $SRS_INGEST = YES ]; then if [ $SRS_FFMPEG = RESERVED ]; then SRS_FFMPEG=YES; fi fi  
242 -  
243 # parse the jobs for make 243 # parse the jobs for make
244 if [[ "" -eq SRS_JOBS ]]; then 244 if [[ "" -eq SRS_JOBS ]]; then
245 export SRS_JOBS="--jobs" 245 export SRS_JOBS="--jobs"
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 listen 19350; 5 listen 19350;
6 daemon on; 6 daemon on;
7 srs_log_tank file; 7 srs_log_tank file;
8 -srs_log_file ./objs/demo.19350.log; 8 +srs_log_file ./objs/srs.demo.19350.log;
9 pid ./objs/srs.demo.19350.pid; 9 pid ./objs/srs.demo.19350.pid;
10 10
11 vhost __defaultVhost__ { 11 vhost __defaultVhost__ {
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 listen 1935; 5 listen 1935;
6 daemon on; 6 daemon on;
7 srs_log_tank file; 7 srs_log_tank file;
8 -srs_log_file ./objs/demo.log; 8 +srs_log_file ./objs/srs.demo.log;
9 pid ./objs/srs.demo.pid; 9 pid ./objs/srs.demo.pid;
10 10
11 chunk_size 60000; 11 chunk_size 60000;
  1 +#!/bin/bash
  2 +
  3 +### BEGIN INIT INFO
  4 +# Provides: simple-rtmp-server(srs)
  5 +# RequiRED-Start: $all
  6 +# RequiRED-Stop: $all
  7 +# Default-Start: 2 3 4 5
  8 +# Default-Stop: 0 1 6
  9 +# Short-Description: simple-rtmp-server(srs)
  10 +# Description: https://github.com/winlinvip/simple-rtmp-server
  11 +### END INIT INFO
  12 +
  13 +# the config of ROOT, user must modify it when start srs from other directory,
  14 +# it's ok to use the script by command ./etc/init.d/simple-rtmp-server
  15 +ROOT="./"
  16 +APP="./objs/srs"
  17 +CONFIG="./conf/demo.conf"
  18 +DEFAULT_PID_FILE='./objs/srs.demo.pid'
  19 +DEFAULT_LOG_FILE='./objs/srs.demo.log'
  20 +
  21 +########################################################################
  22 +# utility functions
  23 +########################################################################
  24 +RED="\\e[31m"
  25 +GREEN="\\e[32m"
  26 +YELLOW="\\e[33m"
  27 +BLACK="\\e[0m"
  28 +POS="\\e[60G"
  29 +
  30 +ok_msg() {
  31 + echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]"
  32 +}
  33 +
  34 +failed_msg() {
  35 + echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]"
  36 +}
  37 +
  38 +# load process info of srs
  39 +# @set variable $srs_pid to the process id in srs.pid file.
  40 +# @return 0, if process exists; otherwise:
  41 +# 1, for pid file not exists.
  42 +# 2, for get proecess info by pid failed.
  43 +# @set variable $error_msg if error.
  44 +# @set variable $pid_file to pid file.
  45 +load_process_info() {
  46 + # get pid file
  47 + pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'`
  48 + if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi
  49 + # get abs path
  50 + pid_dir=`dirname $pid_file`
  51 + pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file`
  52 +
  53 + srs_pid=`cat $pid_file 2>/dev/null`
  54 + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi
  55 +
  56 + ps -p ${srs_pid} >/dev/null 2>/dev/null
  57 + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi
  58 +
  59 + return 0;
  60 +}
  61 +
  62 +start() {
  63 + # if exists, exit.
  64 + load_process_info
  65 + if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi
  66 +
  67 + # not exists, start server
  68 + ok_msg "Starting SRS..."
  69 +
  70 + # get log file
  71 + log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'`
  72 + if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi
  73 + # get abs path
  74 + log_dir=`dirname $log_file`
  75 + log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file`
  76 +
  77 + # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000"
  78 + if [[ -z $log_file ]]; then
  79 + (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
  80 + else
  81 + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1)
  82 + fi
  83 +
  84 + # check again after start server
  85 + for ((i = 0; i < 5; i++)); do
  86 + # sleep a little while, for srs may start then crash.
  87 + sleep 0.1
  88 + load_process_info
  89 + ret=$?; if [[ 0 -ne $ret ]]; then
  90 + failed_msg "SRS start failed";
  91 + failed_msg "see $log_file";
  92 + return $ret;
  93 + fi
  94 + done
  95 +
  96 + # check whether started.
  97 + load_process_info
  98 + ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi
  99 +
  100 + failed_msg "SRS not started"
  101 + return $ret
  102 +}
  103 +
  104 +stop() {
  105 + # not start, exit
  106 + load_process_info
  107 + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
  108 +
  109 + ok_msg "Stopping SRS(pid ${srs_pid})..."
  110 +
  111 + # process exists, kill util stop
  112 + for((;;)); do
  113 + load_process_info
  114 + if [[ 0 -eq $? ]]; then
  115 + kill -s SIGTERM ${srs_pid} 2>/dev/null
  116 + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi
  117 + sleep 0.1
  118 + else
  119 + ok_msg "SRS stopped"
  120 + break;
  121 + fi
  122 + done
  123 +
  124 + sleep 0.1
  125 + return 0
  126 +}
  127 +
  128 +# get the status of srs process
  129 +# @return 0 if srs is running; otherwise, 1 for stopped.
  130 +status() {
  131 + load_process_info
  132 + ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi
  133 +
  134 + echo "SRS is stopped, $error_msg"
  135 + return 1
  136 +}
  137 +
  138 +reload() {
  139 + # not start, exit
  140 + load_process_info
  141 + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
  142 +
  143 + ok_msg "Reload SRS(pid ${srs_pid})..."
  144 +
  145 + # process exists, reload it
  146 + kill -s SIGHUP ${srs_pid} 2>/dev/null
  147 + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi
  148 +
  149 + load_process_info
  150 + if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi
  151 +
  152 + ok_msg "SRS reloaded"
  153 + return 0
  154 +}
  155 +
  156 +menu() {
  157 + case "$1" in
  158 + start)
  159 + start
  160 + ;;
  161 + stop)
  162 + stop
  163 + ;;
  164 + restart)
  165 + stop
  166 + start
  167 + ;;
  168 + status)
  169 + status
  170 + ;;
  171 + reload)
  172 + reload
  173 + ;;
  174 + *)
  175 + echo "Usage: $0 {start|stop|status|restart|reload}"
  176 + return 1
  177 + ;;
  178 + esac
  179 +}
  180 +
  181 +menu $1
  182 +
  183 +code=$?
  184 +exit ${code}
  1 +#!/bin/bash
  2 +
  3 +### BEGIN INIT INFO
  4 +# Provides: simple-rtmp-server(srs)
  5 +# RequiRED-Start: $all
  6 +# RequiRED-Stop: $all
  7 +# Default-Start: 2 3 4 5
  8 +# Default-Stop: 0 1 6
  9 +# Short-Description: simple-rtmp-server(srs)
  10 +# Description: https://github.com/winlinvip/simple-rtmp-server
  11 +### END INIT INFO
  12 +
  13 +# the config of ROOT, user must modify it when start srs from other directory,
  14 +# it's ok to use the script by command ./etc/init.d/simple-rtmp-server
  15 +ROOT="./"
  16 +APP="./objs/srs"
  17 +CONFIG="./conf/demo.19350.conf"
  18 +DEFAULT_PID_FILE='./objs/srs.demo.19350.pid'
  19 +DEFAULT_LOG_FILE='./objs/srs.demo.19350.log'
  20 +
  21 +########################################################################
  22 +# utility functions
  23 +########################################################################
  24 +RED="\\e[31m"
  25 +GREEN="\\e[32m"
  26 +YELLOW="\\e[33m"
  27 +BLACK="\\e[0m"
  28 +POS="\\e[60G"
  29 +
  30 +ok_msg() {
  31 + echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]"
  32 +}
  33 +
  34 +failed_msg() {
  35 + echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]"
  36 +}
  37 +
  38 +# load process info of srs
  39 +# @set variable $srs_pid to the process id in srs.pid file.
  40 +# @return 0, if process exists; otherwise:
  41 +# 1, for pid file not exists.
  42 +# 2, for get proecess info by pid failed.
  43 +# @set variable $error_msg if error.
  44 +# @set variable $pid_file to pid file.
  45 +load_process_info() {
  46 + # get pid file
  47 + pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'`
  48 + if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi
  49 + # get abs path
  50 + pid_dir=`dirname $pid_file`
  51 + pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file`
  52 +
  53 + srs_pid=`cat $pid_file 2>/dev/null`
  54 + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi
  55 +
  56 + ps -p ${srs_pid} >/dev/null 2>/dev/null
  57 + ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi
  58 +
  59 + return 0;
  60 +}
  61 +
  62 +start() {
  63 + # if exists, exit.
  64 + load_process_info
  65 + if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi
  66 +
  67 + # not exists, start server
  68 + ok_msg "Starting SRS..."
  69 +
  70 + # get log file
  71 + log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'`
  72 + if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi
  73 + # get abs path
  74 + log_dir=`dirname $log_file`
  75 + log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file`
  76 +
  77 + # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000"
  78 + if [[ -z $log_file ]]; then
  79 + (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
  80 + else
  81 + (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1)
  82 + fi
  83 +
  84 + # check again after start server
  85 + for ((i = 0; i < 5; i++)); do
  86 + # sleep a little while, for srs may start then crash.
  87 + sleep 0.1
  88 + load_process_info
  89 + ret=$?; if [[ 0 -ne $ret ]]; then
  90 + failed_msg "SRS start failed";
  91 + failed_msg "see $log_file";
  92 + return $ret;
  93 + fi
  94 + done
  95 +
  96 + # check whether started.
  97 + load_process_info
  98 + ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi
  99 +
  100 + failed_msg "SRS not started"
  101 + return $ret
  102 +}
  103 +
  104 +stop() {
  105 + # not start, exit
  106 + load_process_info
  107 + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
  108 +
  109 + ok_msg "Stopping SRS(pid ${srs_pid})..."
  110 +
  111 + # process exists, kill util stop
  112 + for((;;)); do
  113 + load_process_info
  114 + if [[ 0 -eq $? ]]; then
  115 + kill -s SIGTERM ${srs_pid} 2>/dev/null
  116 + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi
  117 + sleep 0.1
  118 + else
  119 + ok_msg "SRS stopped"
  120 + break;
  121 + fi
  122 + done
  123 +
  124 + sleep 0.1
  125 + return 0
  126 +}
  127 +
  128 +# get the status of srs process
  129 +# @return 0 if srs is running; otherwise, 1 for stopped.
  130 +status() {
  131 + load_process_info
  132 + ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi
  133 +
  134 + echo "SRS is stopped, $error_msg"
  135 + return 1
  136 +}
  137 +
  138 +reload() {
  139 + # not start, exit
  140 + load_process_info
  141 + if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi
  142 +
  143 + ok_msg "Reload SRS(pid ${srs_pid})..."
  144 +
  145 + # process exists, reload it
  146 + kill -s SIGHUP ${srs_pid} 2>/dev/null
  147 + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi
  148 +
  149 + load_process_info
  150 + if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi
  151 +
  152 + ok_msg "SRS reloaded"
  153 + return 0
  154 +}
  155 +
  156 +menu() {
  157 + case "$1" in
  158 + start)
  159 + start
  160 + ;;
  161 + stop)
  162 + stop
  163 + ;;
  164 + restart)
  165 + stop
  166 + start
  167 + ;;
  168 + status)
  169 + status
  170 + ;;
  171 + reload)
  172 + reload
  173 + ;;
  174 + *)
  175 + echo "Usage: $0 {start|stop|status|restart|reload}"
  176 + return 1
  177 + ;;
  178 + esac
  179 +}
  180 +
  181 +menu $1
  182 +
  183 +code=$?
  184 +exit ${code}
1 -#!/bin/bash  
2 -for((;;)); do \  
3 - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \  
4 - -vcodec copy -acodec copy \  
5 - -f flv -y rtmp://127.0.0.1/live?vhost=demo.srs.com/livestream; \  
6 - sleep 1; \  
7 -done  
1 -#!/bin/bash  
2 -for((;;)); do \  
3 - ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \  
4 - -vcodec copy -acodec copy \  
5 - -f flv -y rtmp://127.0.0.1/live?vhost=players/demo; \  
6 - sleep 1; \  
7 -done  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -echo "编译SRS"  
6 -./configure --with-ssl --with-hls --with-http-server --with-ffmpeg --with-transcode --with-http-callback && make  
7 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi  
8 -  
9 -echo "编译SRS成功"  
10 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="nohup python ./research/api-server/server.py 8085 >./objs/api-server.log 2>&1 &"  
6 -echo "启动API服务器:$cmd"  
7 -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  
8 -nohup python ./research/api-server/server.py 8085 >./objs/api-server.log 2>&1 &  
9 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi  
10 -  
11 -echo "启动API服务器成功"  
12 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="nohup bash ./scripts/_ffmpeg.demo.sh >./objs/ffmpeg-demo.log 2>&1 &"  
6 -echo "启动FFMPEG推送demo流(播放器上12路演示):$cmd"  
7 -pids=`ps aux|grep scripts|grep "/_ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done  
8 -nohup bash ./scripts/_ffmpeg.demo.sh >./objs/ffmpeg-demo.log 2>&1 &  
9 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送demo流(播放器上12路演示)失败"; exit $ret; fi  
10 -  
11 -echo "启动FFMPEG推送demo流(播放器上12路演示)成功"  
12 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="nohup bash ./scripts/_ffmpeg.players.sh >./objs/ffmpeg-players.log 2>&1 &"  
6 -echo "启动FFMPEG推送players流(播放器上演示用):$cmd"  
7 -pids=`ps aux|grep scripts|grep "/_ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done  
8 -nohup bash ./scripts/_ffmpeg.players.sh >./objs/ffmpeg-players.log 2>&1 &  
9 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动FFMPEG推送players流(播放器上演示用)失败"; exit $ret; fi  
10 -  
11 -echo "启动FFMPEG推送players流(播放器上演示用)成功"  
12 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="sudo ./objs/nginx/sbin/nginx"  
6 -echo "启动NGINX(HLS服务):$cmd"  
7 -if [[ -f ./objs/nginx/logs/nginx.pid ]]; then  
8 - pids=`cat ./objs/nginx/logs/nginx.pid`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGTERM $pid; done  
9 -fi  
10 -sudo ./objs/nginx/sbin/nginx  
11 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动NGINX(HLS服务)失败"; exit $ret; fi  
12 -  
13 -echo "启动NGINX(HLS服务)成功"  
14 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="./objs/srs -c conf/demo.19350.conf"  
6 -echo "启动SRS转发服务器:$cmd"  
7 -pids=`cat ./objs/srs.demo.19350.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done  
8 -./objs/srs -c conf/demo.19350.conf  
9 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi  
10 -  
11 -echo "启动SRS转发服务器成功"  
12 -exit 0  
1 -#!/bin/bash  
2 -src_dir='src'  
3 -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi  
4 -  
5 -cmd="./objs/srs -c conf/demo.conf"  
6 -echo "启动SRS服务器:$cmd"  
7 -pids=`cat ./objs/srs.demo.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done  
8 -./objs/srs -c conf/demo.conf  
9 -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi  
10 -  
11 -echo "启动SRS服务器成功"  
12 -exit 0  
@@ -3,6 +3,8 @@ src_dir='src' @@ -3,6 +3,8 @@ src_dir='src'
3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi 3 if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi
4 4
5 # step 1: build srs 5 # step 1: build srs
6 -bash scripts/_step.build.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi 6 +echo "编译SRS"
  7 +./configure --with-ssl --with-hls --with-http-server --with-ingest --with-transcode --with-http-callback && make
  8 +ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi
7 9
8 echo "编译SRS成功" 10 echo "编译SRS成功"
@@ -8,29 +8,15 @@ GREEN="\\e[32m" @@ -8,29 +8,15 @@ GREEN="\\e[32m"
8 YELLOW="\\e[33m" 8 YELLOW="\\e[33m"
9 BLACK="\\e[0m" 9 BLACK="\\e[0m"
10 10
11 -# step 1: build srs  
12 -#bash scripts/_step.build.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi 11 +./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi
  12 +echo "启动SRS服务器成功"
13 13
14 -# step 2: start srs  
15 -bash scripts/_step.start.srs.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi 14 +./etc/init.d/srs-demo-19350 restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi
  15 +echo "启动SRS转发服务器成功"
16 16
17 -# step 3(optinal): start srs listen at 19350 to forward to  
18 -bash scripts/_step.start.srs.19350.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi 17 +./etc/init.d/srs-api restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi
  18 +echo "启动API服务器成功"
19 19
20 -# REMOVED: for we use srs-http-server instead.  
21 -# step 4(optinal): start nginx for HLS  
22 -#bash scripts/_step.start.nginx.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi  
23 -  
24 -# step 5(optinal): start http hooks for srs callback  
25 -bash scripts/_step.start.api.server.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi  
26 -  
27 -# step 6: publish demo live stream  
28 -#bash scripts/_step.start.ffmpeg.demo.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi  
29 -  
30 -# step 7: publish players live stream  
31 -#bash scripts/_step.start.ffmpeg.players.sh; ret=$?; if [[ 0 -ne $ret ]]; then exit $ret; fi  
32 -  
33 -# step 8: add server ip to client hosts as demo.  
34 ip=`ifconfig|grep "inet"|grep "addr"|grep "Mask"|grep -v "127.0.0.1"|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'` 20 ip=`ifconfig|grep "inet"|grep "addr"|grep "Mask"|grep -v "127.0.0.1"|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'`
35 port=8085 21 port=8085
36 cat<<END 22 cat<<END
1 #!/bin/bash 1 #!/bin/bash
2 2
3 -echo "停止SRS服务器"  
4 -ps aux|grep srs|grep "./objs"|grep "demo.conf"  
5 -pids=`cat ./objs/srs.demo.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done 3 +./etc/init.d/srs-demo stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS失败"; exit $ret; fi
  4 +echo "停止SRS服务器成功"
6 5
7 -echo "停止SRS转发服务器"  
8 -ps aux|grep srs|grep "./objs"|grep "demo.19350.conf"  
9 -pids=`cat ./objs/srs.demo.19350.pid`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done 6 +./etc/init.d/srs-demo-19350 stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS转发服务器失败"; exit $ret; fi
  7 +echo "停止SRS转发服务器成功"
10 8
11 -# REMOVED: for we use srs-http-server instead.  
12 -# step 4(optinal): start nginx for HLS  
13 -#echo "停止NGINX(HLS服务)"  
14 -#ps aux|grep nginx|grep process  
15 -#if [[ -f ./objs/nginx/logs/nginx.pid ]]; then  
16 -# pids=`cat ./objs/nginx/logs/nginx.pid`; for pid in $pids; do echo "结束现有进程:$pid"; sudo kill -s SIGTERM $pid; done  
17 -#fi  
18 -  
19 -# step 5(optinal): start http hooks for srs callback  
20 -echo "停止API服务器"  
21 -ps aux|grep python|grep research|grep "api-server"  
22 -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  
23 -  
24 -# step 6: publish demo live stream  
25 -#echo "停止FFMPEG推送demo流(播放器上12路演示)"  
26 -#ps aux|grep scripts|grep "ffmpeg.demo.sh"  
27 -#pids=`ps aux|grep scripts|grep "/_ffmpeg.demo.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done  
28 -  
29 -# step 7: publish players live stream  
30 -#echo "停止FFMPEG推送players流(播放器上演示用)"  
31 -#ps aux|grep scripts|grep "ffmpeg.players.sh"  
32 -#pids=`ps aux|grep scripts|grep "/_ffmpeg.players.sh"|awk '{print $2}'`; for pid in $pids; do echo "结束现有进程:$pid"; kill -s SIGKILL $pid; done 9 +./etc/init.d/srs-api stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止API服务器失败"; exit $ret; fi
  10 +echo "停止API服务器成功"
33 11
34 echo "SRS系统服务均已停止" 12 echo "SRS系统服务均已停止"