1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix bug of script, support both abs and relative path

This commit is contained in:
winlin 2014-03-25 11:04:36 +08:00
parent c3e750e90f
commit a6d9da5e43
2 changed files with 23 additions and 18 deletions

View file

@ -41,17 +41,17 @@ failed_msg() {
# 1, for pid file not exists.
# 2, for get proecess info by pid failed.
# @set variable $error_msg if error.
# @set variable $srs_pid_file to pid file.
# @set variable $pid_file to pid file.
load_process_info() {
# get pid file
srs_pid_file=`cat ${ROOT}/${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'`
if [[ -z $srs_pid_file ]]; then srs_pid_file=${DEFAULT_PID_FILE}; fi
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
srs_pid_dir=`dirname $srs_pid_file`
srs_pid_file=`(cd ${ROOT}; cd $srs_pid_dir; pwd)`/`basename $srs_pid_file`
pid_dir=`dirname $pid_file`
pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file`
srs_pid=`cat $srs_pid_file 2>/dev/null`
ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $srs_pid_file does not exists"; return 1; fi
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
@ -68,17 +68,17 @@ start() {
ok_msg "Starting SRS..."
# get log file
srs_log_file=`cat ${ROOT}/${CONFIG} |grep '^srs_log_file'| awk '{print $2}'| awk -F ';' '{print $1}'`
if [[ -z $srs_log_file ]]; then srs_log_file=${DEFAULT_LOG_FILE}; fi
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
srs_log_dir=`dirname $srs_log_file`
srs_log_file=`(cd ${ROOT}; cd $srs_log_dir; pwd)`/`basename $srs_log_file`
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 $srs_log_file ]]; then
(cd ${ROOT}; ${ROOT}/${APP} -c ${CONFIG} >/dev/null 2>&1)
if [[ -z $log_file ]]; then
(cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
else
(cd ${ROOT}; ${ROOT}/${APP} -c ${CONFIG} >> $srs_log_file 2>&1)
(cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1)
fi
# check again after start server
@ -86,7 +86,11 @@ start() {
# 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, see $srs_log_file"; return $ret; fi
ret=$?; if [[ 0 -ne $ret ]]; then
failed_msg "SRS start failed";
failed_msg "see $log_file";
return $ret;
fi
done
# check whether started.

View file

@ -131,8 +131,6 @@ int main(int argc, char** argv)
{
int ret = ERROR_SUCCESS;
srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION);
// TODO: support both little and big endian.
srs_assert(srs_is_little_endian());
@ -153,10 +151,13 @@ int main(int argc, char** argv)
#endif
#endif
// never use srs log(srs_trace, srs_error, etc) before config parse the option,
// which will load the log config and apply it.
if ((ret = _srs_config->parse_options(argc, argv)) != ERROR_SUCCESS) {
return ret;
}
srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION);
srs_trace("uname: "SRS_UNAME);
srs_trace("build: %s, %s", SRS_BUILD_DATE, srs_is_little_endian()? "little-endian":"big-endian");
srs_trace("configure: "SRS_CONFIGURE);