diff --git a/README.md b/README.md index d48aeb930..f0775ad5a 100755 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ See also: [Performance Test Guide](https://github.com/winlinvip/simple-rtmp-serv * nginx v1.5.0: 139524 lines
## History -* v1.0, 2014-03-22, support make install and uninstall. +* v1.0, 2014-03-22, support make install/install-api and uninstall. * v1.0, 2014-03-22, add ./etc/init.d/srs, refine to support make clean then make. * v1.0, 2014-03-21, write pid to ./objs/srs.pid. * v1.0, 2014-03-20, refine hls code, support pure audio HLS. diff --git a/trunk/auto/local_ip.sh b/trunk/auto/local_ip.sh new file mode 100755 index 000000000..a6325f049 --- /dev/null +++ b/trunk/auto/local_ip.sh @@ -0,0 +1,6 @@ +ip=`ifconfig 2>&1|grep 'inet addr'|grep -v '127.0.0.1'|awk 'NR==1 {print $2}'|awk -F ':' '{print $2}'` +if [[ -z $ip ]]; then + echo "localhost" +else + echo $ip +fi diff --git a/trunk/configure b/trunk/configure index 84ed93cc6..9e7b7c8f4 100755 --- a/trunk/configure +++ b/trunk/configure @@ -158,7 +158,7 @@ END # makefile echo "generate Makefile" cat << END > ${SRS_MAKEFILE} -.PHONY: default _default install help clean server bandwidth librtmp librtmp-sample utest _prepare_dir +.PHONY: default _default install install-api help clean server bandwidth librtmp librtmp-sample utest _prepare_dir # install prefix. SRS_PREFIX=${SRS_PREFIX} @@ -187,7 +187,7 @@ _default: bandwidth librtmp-sample utest @bash objs/_srs_build_summary.sh help: - @echo "Usage: make |||||||||" + @echo "Usage: make |||||||||" @echo " help display this help menu" @echo " clean cleanup project" @echo " server build the srs(simple rtmp server) over st(state-threads)" @@ -196,7 +196,7 @@ help: @echo " librtmp-sample build the srs-librtmp sample" @echo " utest build the utest for srs" @echo " install install srs to the prefix path" - @echo " install-demo install srs demo to the prefix path" + @echo " install-api install srs api to the prefix path" @echo " uninstall uninstall srs from prefix path" clean: @@ -216,7 +216,7 @@ uninstall: @echo "rmdir \$(SRS_PREFIX)" @rm -rf \$(SRS_PREFIX) -install-demo: install +install-api: install @echo "mkdir \$(SRS_PREFIX)" @mkdir -p \$(SRS_PREFIX) @echo "copy binary files" @@ -233,6 +233,12 @@ install-demo: install @mkdir -p \$(SRS_PREFIX)/etc/init.d @cp etc/init.d/srs-api \$(SRS_PREFIX)/etc/init.d @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs-api + @echo "" + @echo "api installed, to link and start api:" + @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs-api /etc/init.d/srs-api" + @echo " /etc/init.d/srs-api start" + @echo " http://$(shell bash auto/local_ip.sh):8085" + @echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService" install: @echo "mkdir \$(SRS_PREFIX)" @@ -247,6 +253,11 @@ install: @mkdir -p \$(SRS_PREFIX)/etc/init.d @cp etc/init.d/srs \$(SRS_PREFIX)/etc/init.d @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(SRS_PREFIX)/etc/init.d/srs + @echo "" + @echo "srs installed, to link and start srs:" + @echo " sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs" + @echo " /etc/init.d/srs start" + @echo "@see: https://github.com/winlinvip/simple-rtmp-server/wiki/LinuxService" END diff --git a/trunk/etc/init.d/srs b/trunk/etc/init.d/srs index 16ea03879..9b7bf849c 100755 --- a/trunk/etc/init.d/srs +++ b/trunk/etc/init.d/srs @@ -71,6 +71,15 @@ start() { (cd ${ROOT}; nohup ${APP} -c ${CONFIG} >/dev/null 2>&1 &) # check again after start server + sleep 0.5 + 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"; 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