正在显示
5 个修改的文件
包含
37 行增加
和
14 行删除
| @@ -2175,6 +2175,16 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj) | @@ -2175,6 +2175,16 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj) | ||
| 2175 | return ret; | 2175 | return ret; |
| 2176 | } | 2176 | } |
| 2177 | 2177 | ||
| 2178 | +int SrsConfig::raw_set_listen(const vector<string>& eps) | ||
| 2179 | +{ | ||
| 2180 | + int ret = ERROR_SUCCESS; | ||
| 2181 | + | ||
| 2182 | + SrsConfDirective* listen = root->get("listen"); | ||
| 2183 | + listen->args = eps; | ||
| 2184 | + | ||
| 2185 | + return ret; | ||
| 2186 | +} | ||
| 2187 | + | ||
| 2178 | string SrsConfig::config() | 2188 | string SrsConfig::config() |
| 2179 | { | 2189 | { |
| 2180 | return config_file; | 2190 | return config_file; |
| @@ -329,6 +329,10 @@ public: | @@ -329,6 +329,10 @@ public: | ||
| 329 | * dumps the http_api sections to json for raw api info. | 329 | * dumps the http_api sections to json for raw api info. |
| 330 | */ | 330 | */ |
| 331 | virtual int raw_to_json(SrsAmf0Object* obj); | 331 | virtual int raw_to_json(SrsAmf0Object* obj); |
| 332 | + /** | ||
| 333 | + * raw set the global listen. | ||
| 334 | + */ | ||
| 335 | + virtual int raw_set_listen(const std::vector<std::string>& eps); | ||
| 332 | public: | 336 | public: |
| 333 | /** | 337 | /** |
| 334 | * get the config file path. | 338 | * get the config file path. |
| @@ -1006,11 +1006,20 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1006,11 +1006,20 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1006 | } | 1006 | } |
| 1007 | if (invalid) { | 1007 | if (invalid) { |
| 1008 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; | 1008 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; |
| 1009 | - srs_error("raw api update global.listen invalid eps=%s. ret=%d", value.c_str(), ret); | 1009 | + srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret); |
| 1010 | + return srs_api_response_code(w, r, ret); | ||
| 1011 | + } | ||
| 1012 | + | ||
| 1013 | + if ((ret = _srs_config->raw_set_listen(eps)) != ERROR_SUCCESS) { | ||
| 1014 | + srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret); | ||
| 1010 | return srs_api_response_code(w, r, ret); | 1015 | return srs_api_response_code(w, r, ret); |
| 1011 | } | 1016 | } |
| 1012 | } | 1017 | } |
| 1013 | 1018 | ||
| 1019 | + server->on_signal(SRS_SIGNAL_RELOAD); | ||
| 1020 | + server->on_signal(SRS_SIGNAL_PERSISTENCE_CONFIG); | ||
| 1021 | + srs_trace("raw api update %s=%s ok.", scope.c_str(), value.c_str()); | ||
| 1022 | + | ||
| 1014 | return srs_api_response(w, r, obj->to_json()); | 1023 | return srs_api_response(w, r, obj->to_json()); |
| 1015 | } | 1024 | } |
| 1016 | 1025 |
| @@ -995,18 +995,6 @@ int SrsServer::do_cycle() | @@ -995,18 +995,6 @@ int SrsServer::do_cycle() | ||
| 995 | } | 995 | } |
| 996 | #endif | 996 | #endif |
| 997 | 997 | ||
| 998 | - // do reload the config. | ||
| 999 | - if (signal_reload) { | ||
| 1000 | - signal_reload = false; | ||
| 1001 | - srs_info("get signal to reload the config."); | ||
| 1002 | - | ||
| 1003 | - if ((ret = _srs_config->reload()) != ERROR_SUCCESS) { | ||
| 1004 | - srs_error("reload config failed. ret=%d", ret); | ||
| 1005 | - return ret; | ||
| 1006 | - } | ||
| 1007 | - srs_trace("reload config success."); | ||
| 1008 | - } | ||
| 1009 | - | ||
| 1010 | // do persistence config to file. | 998 | // do persistence config to file. |
| 1011 | if (signal_persistence_config) { | 999 | if (signal_persistence_config) { |
| 1012 | signal_persistence_config = false; | 1000 | signal_persistence_config = false; |
| @@ -1019,6 +1007,18 @@ int SrsServer::do_cycle() | @@ -1019,6 +1007,18 @@ int SrsServer::do_cycle() | ||
| 1019 | srs_trace("persistence config to file success."); | 1007 | srs_trace("persistence config to file success."); |
| 1020 | } | 1008 | } |
| 1021 | 1009 | ||
| 1010 | + // do reload the config. | ||
| 1011 | + if (signal_reload) { | ||
| 1012 | + signal_reload = false; | ||
| 1013 | + srs_info("get signal to reload the config."); | ||
| 1014 | + | ||
| 1015 | + if ((ret = _srs_config->reload()) != ERROR_SUCCESS) { | ||
| 1016 | + srs_error("reload config failed. ret=%d", ret); | ||
| 1017 | + return ret; | ||
| 1018 | + } | ||
| 1019 | + srs_trace("reload config success."); | ||
| 1020 | + } | ||
| 1021 | + | ||
| 1022 | // notice the stream sources to cycle. | 1022 | // notice the stream sources to cycle. |
| 1023 | if ((ret = SrsSource::cycle_all()) != ERROR_SUCCESS) { | 1023 | if ((ret = SrsSource::cycle_all()) != ERROR_SUCCESS) { |
| 1024 | return ret; | 1024 | return ret; |
-
请 注册 或 登录 后发表评论