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
2015-08-26 21:11:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
980e3921e40fc0b0ced66dd45fd2a410e77e3949
980e3921
1 parent
cdde2937
for #319, add signal to write config to file.
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
46 行增加
和
5 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
980e392
...
...
@@ -1421,6 +1421,13 @@ int SrsConfig::parse_options(int argc, char** argv)
return
ret
;
}
int
SrsConfig
::
persistence
()
{
int
ret
=
ERROR_SUCCESS
;
// TODO: FIXME: implements it.
return
ret
;
}
string
SrsConfig
::
config
()
{
return
config_file
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
980e392
...
...
@@ -288,6 +288,10 @@ public:
*/
virtual
int
parse_options
(
int
argc
,
char
**
argv
);
/**
* persistence current config to file.
*/
virtual
int
persistence
();
/**
* get the config file path.
*/
virtual
std
::
string
config
();
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
980e392
...
...
@@ -50,7 +50,13 @@ using namespace std;
#include <srs_core_mem_watch.hpp>
// signal defines.
#define SIGNAL_RELOAD SIGHUP
// reload the config file and apply new config.
#define SRS_SIGNAL_RELOAD SIGHUP
// terminate the srs with dispose to detect memory leak for gmp.
#define SRS_SIGNAL_DISPOSE SIGUSR2
// persistence the config in memory to config file.
// @see https://github.com/simple-rtmp-server/srs/issues/319#issuecomment-134993922
#define SRS_SIGNAL_PERSISTENCE_CONFIG SIGUSR1
// system interval in ms,
// all resolution times should be times togother,
...
...
@@ -419,7 +425,7 @@ int SrsSignalManager::start()
sa
.
sa_handler
=
SrsSignalManager
::
sig_catcher
;
sigemptyset
(
&
sa
.
sa_mask
);
sa
.
sa_flags
=
0
;
sigaction
(
SIGNAL_RELOAD
,
&
sa
,
NULL
);
sigaction
(
S
RS_S
IGNAL_RELOAD
,
&
sa
,
NULL
);
sa
.
sa_handler
=
SrsSignalManager
::
sig_catcher
;
sigemptyset
(
&
sa
.
sa_mask
);
...
...
@@ -434,7 +440,12 @@ int SrsSignalManager::start()
sa
.
sa_handler
=
SrsSignalManager
::
sig_catcher
;
sigemptyset
(
&
sa
.
sa_mask
);
sa
.
sa_flags
=
0
;
sigaction
(
SIGUSR2
,
&
sa
,
NULL
);
sigaction
(
SRS_SIGNAL_DISPOSE
,
&
sa
,
NULL
);
sa
.
sa_handler
=
SrsSignalManager
::
sig_catcher
;
sigemptyset
(
&
sa
.
sa_mask
);
sa
.
sa_flags
=
0
;
sigaction
(
SRS_SIGNAL_PERSISTENCE_CONFIG
,
&
sa
,
NULL
);
srs_trace
(
"signal installed"
);
...
...
@@ -481,6 +492,7 @@ ISrsServerCycle::~ISrsServerCycle()
SrsServer
::
SrsServer
()
{
signal_reload
=
false
;
signal_persistence_config
=
false
;
signal_gmc_stop
=
false
;
signal_gracefully_quit
=
false
;
pid_fd
=
-
1
;
...
...
@@ -905,11 +917,16 @@ void SrsServer::remove(SrsConnection* conn)
void
SrsServer
::
on_signal
(
int
signo
)
{
if
(
signo
==
SIGNAL_RELOAD
)
{
if
(
signo
==
S
RS_S
IGNAL_RELOAD
)
{
signal_reload
=
true
;
return
;
}
if
(
signo
==
SRS_SIGNAL_PERSISTENCE_CONFIG
)
{
signal_persistence_config
=
true
;
return
;
}
if
(
signo
==
SIGINT
||
signo
==
SIGUSR2
)
{
#ifdef SRS_AUTO_GPERF_MC
srs_trace
(
"gmc is on, main cycle will terminate normally."
);
...
...
@@ -986,7 +1003,7 @@ int SrsServer::do_cycle()
// do reload the config.
if
(
signal_reload
)
{
signal_reload
=
false
;
srs_info
(
"get signal
reload,
to reload the config."
);
srs_info
(
"get signal to reload the config."
);
if
((
ret
=
_srs_config
->
reload
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"reload config failed. ret=%d"
,
ret
);
...
...
@@ -995,6 +1012,18 @@ int SrsServer::do_cycle()
srs_trace
(
"reload config success."
);
}
// do persistence config to file.
if
(
signal_persistence_config
)
{
signal_persistence_config
=
false
;
srs_info
(
"get signal to persistence config to file."
);
if
((
ret
=
_srs_config
->
persistence
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"persistence config to file failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"persistence config to file success."
);
}
// notice the stream sources to cycle.
if
((
ret
=
SrsSource
::
cycle_all
())
!=
ERROR_SUCCESS
)
{
return
ret
;
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
980e392
...
...
@@ -275,6 +275,7 @@ private:
* user send the signal, convert to variable.
*/
bool
signal_reload
;
bool
signal_persistence_config
;
bool
signal_gmc_stop
;
bool
signal_gracefully_quit
;
public
:
...
...
请
注册
或
登录
后发表评论