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:
parent
f8d8c3ace4
commit
364460f2ab
5 changed files with 37 additions and 14 deletions
|
@ -7,7 +7,7 @@ daemon off;
|
|||
http_api {
|
||||
enabled on;
|
||||
listen 1985;
|
||||
#crossdomain on;
|
||||
crossdomain on;
|
||||
raw_api {
|
||||
enabled on;
|
||||
allow_reload on;
|
||||
|
|
|
@ -2175,6 +2175,16 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj)
|
|||
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()
|
||||
{
|
||||
return config_file;
|
||||
|
|
|
@ -329,6 +329,10 @@ public:
|
|||
* dumps the http_api sections to json for raw api info.
|
||||
*/
|
||||
virtual int raw_to_json(SrsAmf0Object* obj);
|
||||
/**
|
||||
* raw set the global listen.
|
||||
*/
|
||||
virtual int raw_set_listen(const std::vector<std::string>& eps);
|
||||
public:
|
||||
/**
|
||||
* get the config file path.
|
||||
|
|
|
@ -1006,11 +1006,20 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
}
|
||||
if (invalid) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -994,18 +994,6 @@ int SrsServer::do_cycle()
|
|||
return ret;
|
||||
}
|
||||
#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.
|
||||
if (signal_persistence_config) {
|
||||
|
@ -1018,6 +1006,18 @@ int SrsServer::do_cycle()
|
|||
}
|
||||
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.
|
||||
if ((ret = SrsSource::cycle_all()) != ERROR_SUCCESS) {
|
||||
|
|
Loading…
Reference in a new issue