mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
for #319, support raw update global.listen
This commit is contained in:
parent
f8d8c3ace4
commit
364460f2ab
5 changed files with 37 additions and 14 deletions
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -995,18 +995,6 @@ int SrsServer::do_cycle()
|
||||||
}
|
}
|
||||||
#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) {
|
||||||
signal_persistence_config = false;
|
signal_persistence_config = false;
|
||||||
|
@ -1019,6 +1007,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) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue