winlin

fix bug of init.d script

... ... @@ -169,7 +169,7 @@ See also: [Performance Test Guide](https://github.com/winlinvip/simple-rtmp-serv
* nginx v1.5.0: 139524 lines <br/>
## 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.
... ...
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
... ...
... ... @@ -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 <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>|<utest>|<install>|<install-demo>|<uninstall>"
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>|<utest>|<install>|<install-api>|<uninstall>"
@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
... ...
... ... @@ -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
... ...