1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 11:21:52 +00:00

for #319, support raw update global.listen

This commit is contained in:
winlin 2015-08-30 23:18:14 +08:00
parent f8d8c3ace4
commit 364460f2ab
5 changed files with 37 additions and 14 deletions

View file

@ -7,7 +7,7 @@ daemon off;
http_api { http_api {
enabled on; enabled on;
listen 1985; listen 1985;
#crossdomain on; crossdomain on;
raw_api { raw_api {
enabled on; enabled on;
allow_reload on; allow_reload on;

View file

@ -2175,6 +2175,16 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj)
return ret; return ret;
} }
int SrsConfig::raw_set_listen(const vector<string>& eps)
{
int ret = ERROR_SUCCESS;
SrsConfDirective* listen = root->get("listen");
listen->args = eps;
return ret;
}
string SrsConfig::config() string SrsConfig::config()
{ {
return config_file; return config_file;

View file

@ -329,6 +329,10 @@ public:
* dumps the http_api sections to json for raw api info. * dumps the http_api sections to json for raw api info.
*/ */
virtual int raw_to_json(SrsAmf0Object* obj); virtual int raw_to_json(SrsAmf0Object* obj);
/**
* raw set the global listen.
*/
virtual int raw_set_listen(const std::vector<std::string>& eps);
public: public:
/** /**
* get the config file path. * get the config file path.

View file

@ -1006,11 +1006,20 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
} }
if (invalid) { if (invalid) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
srs_error("raw api update global.listen invalid eps=%s. ret=%d", value.c_str(), ret); srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
return srs_api_response_code(w, r, ret);
}
if ((ret = _srs_config->raw_set_listen(eps)) != ERROR_SUCCESS) {
srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
return srs_api_response_code(w, r, ret); return srs_api_response_code(w, r, ret);
} }
} }
server->on_signal(SRS_SIGNAL_RELOAD);
server->on_signal(SRS_SIGNAL_PERSISTENCE_CONFIG);
srs_trace("raw api update %s=%s ok.", scope.c_str(), value.c_str());
return srs_api_response(w, r, obj->to_json()); return srs_api_response(w, r, obj->to_json());
} }

View file

@ -994,18 +994,6 @@ int SrsServer::do_cycle()
return ret; return ret;
} }
#endif #endif
// do reload the config.
if (signal_reload) {
signal_reload = false;
srs_info("get signal to reload the config.");
if ((ret = _srs_config->reload()) != ERROR_SUCCESS) {
srs_error("reload config failed. ret=%d", ret);
return ret;
}
srs_trace("reload config success.");
}
// do persistence config to file. // do persistence config to file.
if (signal_persistence_config) { if (signal_persistence_config) {
@ -1018,6 +1006,18 @@ int SrsServer::do_cycle()
} }
srs_trace("persistence config to file success."); srs_trace("persistence config to file success.");
} }
// do reload the config.
if (signal_reload) {
signal_reload = false;
srs_info("get signal to reload the config.");
if ((ret = _srs_config->reload()) != ERROR_SUCCESS) {
srs_error("reload config failed. ret=%d", ret);
return ret;
}
srs_trace("reload config success.");
}
// notice the stream sources to cycle. // notice the stream sources to cycle.
if ((ret = SrsSource::cycle_all()) != ERROR_SUCCESS) { if ((ret = SrsSource::cycle_all()) != ERROR_SUCCESS) {