mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
refine reload config
This commit is contained in:
parent
bc61b1de18
commit
6c5d8b4851
4 changed files with 63 additions and 62 deletions
|
@ -221,7 +221,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
|
|||
* nginx v1.5.0: 139524 lines <br/>
|
||||
|
||||
## History
|
||||
* v1.0, 2014-04-10, support reload ingesters(added/removed/updated). change to 0.9.57.
|
||||
* v1.0, 2014-04-10, support reload ingesters(add/remov/update). change to 0.9.57.
|
||||
* v1.0, 2014-04-07, [1.0 mainline(0.9.55)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline) released. 30000 lines.
|
||||
* v1.0, 2014-04-07, support [ingest](https://github.com/winlinvip/simple-rtmp-server/wiki/SampleIngest) file/stream/device.
|
||||
* v1.0, 2014-04-05, support [http api](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPApi) and [http server](https://github.com/winlinvip/simple-rtmp-server/wiki/HTTPServer).
|
||||
|
|
|
@ -447,6 +447,30 @@ SrsConfig::~SrsConfig()
|
|||
srs_freep(root);
|
||||
}
|
||||
|
||||
void SrsConfig::subscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
||||
it = std::find(subscribes.begin(), subscribes.end(), handler);
|
||||
if (it != subscribes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
subscribes.push_back(handler);
|
||||
}
|
||||
|
||||
void SrsConfig::unsubscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
||||
it = std::find(subscribes.begin(), subscribes.end(), handler);
|
||||
if (it == subscribes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
subscribes.erase(it);
|
||||
}
|
||||
|
||||
int SrsConfig::reload()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -630,62 +654,6 @@ int SrsConfig::reload()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsConfig::subscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
||||
it = std::find(subscribes.begin(), subscribes.end(), handler);
|
||||
if (it != subscribes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
subscribes.push_back(handler);
|
||||
}
|
||||
|
||||
void SrsConfig::unsubscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
||||
it = std::find(subscribes.begin(), subscribes.end(), handler);
|
||||
if (it == subscribes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
subscribes.erase(it);
|
||||
}
|
||||
|
||||
// see: ngx_get_options
|
||||
int SrsConfig::parse_options(int argc, char** argv)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if ((ret = parse_argv(i, argv)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_help) {
|
||||
print_help(argv);
|
||||
}
|
||||
|
||||
if (show_version) {
|
||||
fprintf(stderr, "%s\n", RTMP_SIG_SRS_VERSION);
|
||||
}
|
||||
|
||||
if (show_help || show_version) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config_file.empty()) {
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("config file not specified, see help: %s -h, ret=%d", argv[0], ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return parse_file(config_file.c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -870,6 +838,38 @@ int SrsConfig::reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_
|
|||
return ret;
|
||||
}
|
||||
|
||||
// see: ngx_get_options
|
||||
int SrsConfig::parse_options(int argc, char** argv)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if ((ret = parse_argv(i, argv)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (show_help) {
|
||||
print_help(argv);
|
||||
}
|
||||
|
||||
if (show_version) {
|
||||
fprintf(stderr, "%s\n", RTMP_SIG_SRS_VERSION);
|
||||
}
|
||||
|
||||
if (show_help || show_version) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config_file.empty()) {
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("config file not specified, see help: %s -h, ret=%d", argv[0], ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return parse_file(config_file.c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::parse_file(const char* filename)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
|
|
@ -119,14 +119,15 @@ public:
|
|||
SrsConfig();
|
||||
virtual ~SrsConfig();
|
||||
public:
|
||||
virtual int reload();
|
||||
virtual void subscribe(ISrsReloadHandler* handler);
|
||||
virtual void unsubscribe(ISrsReloadHandler* handler);
|
||||
virtual int reload();
|
||||
private:
|
||||
virtual int reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
||||
virtual int reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
||||
public:
|
||||
virtual int parse_options(int argc, char** argv);
|
||||
private:
|
||||
virtual int reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
||||
virtual int reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
||||
virtual int parse_file(const char* filename);
|
||||
virtual int parse_argv(int& i, char** argv);
|
||||
virtual void print_help(char** argv);
|
||||
|
|
|
@ -131,11 +131,11 @@ extern ISrsThreadContext* _srs_context;
|
|||
#define srs_error(msg, ...) _srs_log->error(__PRETTY_FUNCTION__, _srs_context->get_id(), msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
#undef srs_verbose
|
||||
#define srs_verbose(msg, ...) (void)0
|
||||
#endif
|
||||
#if 1
|
||||
#if 0
|
||||
#undef srs_info
|
||||
#define srs_info(msg, ...) (void)0
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue