winlin

for #319, support raw update global.listen

@@ -7,7 +7,7 @@ daemon off; @@ -7,7 +7,7 @@ daemon off;
7 http_api { 7 http_api {
8 enabled on; 8 enabled on;
9 listen 1985; 9 listen 1985;
10 - #crossdomain on; 10 + crossdomain on;
11 raw_api { 11 raw_api {
12 enabled on; 12 enabled on;
13 allow_reload on; 13 allow_reload on;
@@ -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
@@ -994,18 +994,6 @@ int SrsServer::do_cycle() @@ -994,18 +994,6 @@ int SrsServer::do_cycle()
994 return ret; 994 return ret;
995 } 995 }
996 #endif 996 #endif
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 997
1010 // do persistence config to file. 998 // do persistence config to file.
1011 if (signal_persistence_config) { 999 if (signal_persistence_config) {
@@ -1018,6 +1006,18 @@ int SrsServer::do_cycle() @@ -1018,6 +1006,18 @@ int SrsServer::do_cycle()
1018 } 1006 }
1019 srs_trace("persistence config to file success."); 1007 srs_trace("persistence config to file success.");
1020 } 1008 }
  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 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) {