Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-03-23 12:42:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ec3c1f53205f84020a77c25883b321bbbd27f39
3ec3c1f5
1 parent
2c1354b9
support daemon
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
102 行增加
和
29 行删除
trunk/conf/full.conf
trunk/etc/init.d/srs
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/main/srs_main_server.cpp
trunk/conf/full.conf
查看文件 @
3ec3c1f
...
...
@@ -19,13 +19,17 @@ chunk_size 60000;
# default: ./objs/logs
ff_log_dir
./
objs
/
logs
;
# the log file for srs.
# if not specified, disable log to file, only print to console.
# if not specified
or empty
, disable log to file, only print to console.
# if speicfied, write log to file and print to console.
# default: empty.
srs_log_file
./
objs
/
srs
.
log
;
# the max connections.
# if exceed the max connections, server will drop the new connection.
# default: 2000
max_connections
1000
;
# whether start as deamon
# default: on
daemon
on
;
# vhost list, the __defaultVhost__ is the default vhost
# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream.
# for which cannot identify the required vhost.
...
...
trunk/etc/init.d/srs
查看文件 @
3ec3c1f
...
...
@@ -71,11 +71,10 @@ start() {
srs_log_file
=
`
cat
${
ROOT
}
/
${
CONFIG
}
|grep
'^srs_log_file'
| awk
'{print $2}'
| awk -F
';'
'{print $1}'
`
# TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000"
# TODO: FIXME: support deamon, without nohup.
if
[[
-z
$srs_log_file
]]
;
then
(
cd
${
ROOT
}
;
nohup
${
APP
}
-c
${
CONFIG
}
>/dev/null 2>&1 &
)
(
cd
${
ROOT
}
;
${
APP
}
-c
${
CONFIG
}
>/dev/null 2>&1
)
else
(
cd
${
ROOT
}
;
nohup
${
APP
}
-c
${
CONFIG
}
>>
$srs_log_file
2>&1 &
)
(
cd
${
ROOT
}
;
${
APP
}
-c
${
CONFIG
}
>>
$srs_log_file
2>&1
)
fi
# check again after start server
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
3ec3c1f
...
...
@@ -1282,6 +1282,18 @@ string SrsConfig::get_srs_log_file()
return
conf
->
arg0
();
}
bool
SrsConfig
::
get_deamon
()
{
srs_assert
(
root
);
SrsConfDirective
*
conf
=
root
->
get
(
"deamon"
);
if
(
conf
&&
conf
->
arg0
()
==
"off"
)
{
return
false
;
}
return
true
;
}
int
SrsConfig
::
get_max_connections
()
{
srs_assert
(
root
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
3ec3c1f
...
...
@@ -149,6 +149,7 @@ public:
virtual
std
::
string
get_engine_output
(
SrsConfDirective
*
engine
);
virtual
std
::
string
get_ffmpeg_log_dir
();
virtual
std
::
string
get_srs_log_file
();
virtual
bool
get_deamon
();
virtual
int
get_max_connections
();
virtual
bool
get_gop_cache
(
std
::
string
vhost
);
virtual
double
get_queue_length
(
std
::
string
vhost
);
...
...
trunk/src/main/srs_main_server.cpp
查看文件 @
3ec3c1f
...
...
@@ -37,6 +37,9 @@ SrsServer* _srs_server = new SrsServer();
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef SRS_GPERF_MP
#include <gperftools/heap-profiler.h>
#endif
...
...
@@ -50,38 +53,14 @@ void handler(int signo)
_srs_server
->
on_signal
(
signo
);
}
int
main
(
int
argc
,
char
**
argv
)
int
run_master
(
)
{
int
ret
=
ERROR_SUCCESS
;
// TODO: support both little and big endian.
srs_assert
(
srs_is_little_endian
());
#ifdef SRS_GPERF_MP
HeapProfilerStart
(
"gperf.srs.gmp"
);
#endif
#ifdef SRS_GPERF_CP
ProfilerStart
(
"gperf.srs.gcp"
);
#endif
signal
(
SIGNAL_RELOAD
,
handler
);
signal
(
SIGTERM
,
handler
);
signal
(
SIGINT
,
handler
);
if
((
ret
=
_srs_config
->
parse_options
(
argc
,
argv
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#ifdef SRS_GPERF_MC
#ifdef SRS_GPERF_MP
srs_error
(
"option --with-gmc confict with --with-gmp, "
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
\n
"
"Note that since the heap-checker uses the heap-profiling framework internally, "
"it is not possible to run both the heap-checker and heap profiler at the same time"
);
return
-
1
;
#endif
#endif
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
);
...
...
@@ -106,3 +85,81 @@ int main(int argc, char** argv)
return
0
;
}
int
run
()
{
// if not deamon, directly run master.
if
(
!
_srs_config
->
get_deamon
())
{
return
run_master
();
}
srs_trace
(
"start deamon mode..."
);
int
pid
=
fork
();
if
(
pid
==
-
1
){
srs_error
(
"create process error. ret=-1"
);
//ret=0
return
-
1
;
}
// grandpa
if
(
pid
>
0
){
int
status
=
0
;
if
(
waitpid
(
pid
,
&
status
,
0
)
==
-
1
){
srs_error
(
"wait child process error! ret=-1"
);
//ret=0
}
srs_trace
(
"grandpa process exit."
);
exit
(
0
);
return
0
;
}
// father
pid
=
fork
();
if
(
pid
==
-
1
){
srs_error
(
"create process error. ret=-1"
);
return
-
1
;
}
if
(
pid
>
0
){
srs_trace
(
"father process exit. ret=-1"
);
exit
(
0
);
return
0
;
}
// son
srs_trace
(
"son(deamon) process running."
);
return
run_master
();
}
int
main
(
int
argc
,
char
**
argv
)
{
int
ret
=
ERROR_SUCCESS
;
// TODO: support both little and big endian.
srs_assert
(
srs_is_little_endian
());
#ifdef SRS_GPERF_MP
HeapProfilerStart
(
"gperf.srs.gmp"
);
#endif
#ifdef SRS_GPERF_CP
ProfilerStart
(
"gperf.srs.gcp"
);
#endif
#ifdef SRS_GPERF_MC
#ifdef SRS_GPERF_MP
srs_error
(
"option --with-gmc confict with --with-gmp, "
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
\n
"
"Note that since the heap-checker uses the heap-profiling framework internally, "
"it is not possible to run both the heap-checker and heap profiler at the same time"
);
return
-
1
;
#endif
#endif
if
((
ret
=
_srs_config
->
parse_options
(
argc
,
argv
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
run
();
}
...
...
请
注册
或
登录
后发表评论