winlin

remove the config log http api. 0.9.148

@@ -539,24 +539,39 @@ int SrsConfig::reload() @@ -539,24 +539,39 @@ int SrsConfig::reload()
539 539
540 // merge config: srs_log_tank 540 // merge config: srs_log_tank
541 if (!srs_directive_equals(root->get("srs_log_tank"), old_root->get("srs_log_tank"))) { 541 if (!srs_directive_equals(root->get("srs_log_tank"), old_root->get("srs_log_tank"))) {
542 - if ((ret = force_reload_log_tank()) != ERROR_SUCCESS) { 542 + for (it = subscribes.begin(); it != subscribes.end(); ++it) {
  543 + ISrsReloadHandler* subscribe = *it;
  544 + if ((ret = subscribe->on_reload_log_tank()) != ERROR_SUCCESS) {
  545 + srs_error("notify subscribes reload srs_log_tank failed. ret=%d", ret);
543 return ret; 546 return ret;
544 } 547 }
545 } 548 }
  549 + srs_trace("reload srs_log_tank success.");
  550 + }
546 551
547 // merge config: srs_log_level 552 // merge config: srs_log_level
548 if (!srs_directive_equals(root->get("srs_log_level"), old_root->get("srs_log_level"))) { 553 if (!srs_directive_equals(root->get("srs_log_level"), old_root->get("srs_log_level"))) {
549 - if ((ret = force_reload_log_level()) != ERROR_SUCCESS) { 554 + for (it = subscribes.begin(); it != subscribes.end(); ++it) {
  555 + ISrsReloadHandler* subscribe = *it;
  556 + if ((ret = subscribe->on_reload_log_level()) != ERROR_SUCCESS) {
  557 + srs_error("notify subscribes reload srs_log_level failed. ret=%d", ret);
550 return ret; 558 return ret;
551 } 559 }
552 } 560 }
  561 + srs_trace("reload srs_log_level success.");
  562 + }
553 563
554 // merge config: srs_log_file 564 // merge config: srs_log_file
555 if (!srs_directive_equals(root->get("srs_log_file"), old_root->get("srs_log_file"))) { 565 if (!srs_directive_equals(root->get("srs_log_file"), old_root->get("srs_log_file"))) {
556 - if ((ret = force_reload_log_file()) != ERROR_SUCCESS) { 566 + for (it = subscribes.begin(); it != subscribes.end(); ++it) {
  567 + ISrsReloadHandler* subscribe = *it;
  568 + if ((ret = subscribe->on_reload_log_file()) != ERROR_SUCCESS) {
  569 + srs_error("notify subscribes reload srs_log_file failed. ret=%d", ret);
557 return ret; 570 return ret;
558 } 571 }
559 } 572 }
  573 + srs_trace("reload srs_log_file success.");
  574 + }
560 575
561 // merge config: pithy_print 576 // merge config: pithy_print
562 if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) { 577 if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) {
@@ -603,102 +618,6 @@ SrsConfDirective* SrsConfig::get_or_create(SrsConfDirective* node, string name) @@ -603,102 +618,6 @@ SrsConfDirective* SrsConfig::get_or_create(SrsConfDirective* node, string name)
603 return conf; 618 return conf;
604 } 619 }
605 620
606 -bool SrsConfig::set_log_file(string file)  
607 -{  
608 - if (file == get_log_file()) {  
609 - return false;  
610 - }  
611 -  
612 - SrsConfDirective* conf = get_or_create(root, "srs_log_file");  
613 - srs_assert(conf);  
614 - conf->set_arg0(file);  
615 -  
616 - return true;  
617 -}  
618 -  
619 -bool SrsConfig::set_log_tank(string tank)  
620 -{  
621 - if (get_log_tank_file() && tank != "console") {  
622 - return false;  
623 - }  
624 - if (!get_log_tank_file() && tank == "console") {  
625 - return false;  
626 - }  
627 -  
628 - SrsConfDirective* conf = get_or_create(root, "srs_log_tank");  
629 - srs_assert(conf);  
630 - conf->set_arg0(tank);  
631 -  
632 - return true;  
633 -}  
634 -  
635 -bool SrsConfig::set_log_level(string level)  
636 -{  
637 - if (level == get_log_level()) {  
638 - return false;  
639 - }  
640 -  
641 - SrsConfDirective* conf = get_or_create(root, "srs_log_level");  
642 - srs_assert(conf);  
643 - conf->set_arg0(level);  
644 -  
645 - return true;  
646 -}  
647 -  
648 -int SrsConfig::force_reload_log_file()  
649 -{  
650 - int ret = ERROR_SUCCESS;  
651 -  
652 - std::vector<ISrsReloadHandler*>::iterator it;  
653 -  
654 - for (it = subscribes.begin(); it != subscribes.end(); ++it) {  
655 - ISrsReloadHandler* subscribe = *it;  
656 - if ((ret = subscribe->on_reload_log_file()) != ERROR_SUCCESS) {  
657 - srs_error("notify subscribes reload srs_log_file failed. ret=%d", ret);  
658 - return ret;  
659 - }  
660 - }  
661 - srs_trace("reload srs_log_file success.");  
662 -  
663 - return ret;  
664 -}  
665 -  
666 -int SrsConfig::force_reload_log_tank()  
667 -{  
668 - int ret = ERROR_SUCCESS;  
669 -  
670 - std::vector<ISrsReloadHandler*>::iterator it;  
671 -  
672 - for (it = subscribes.begin(); it != subscribes.end(); ++it) {  
673 - ISrsReloadHandler* subscribe = *it;  
674 - if ((ret = subscribe->on_reload_log_tank()) != ERROR_SUCCESS) {  
675 - srs_error("notify subscribes reload srs_log_tank failed. ret=%d", ret);  
676 - return ret;  
677 - }  
678 - }  
679 - srs_trace("reload srs_log_tank success.");  
680 -  
681 - return ret;  
682 -}  
683 -  
684 -int SrsConfig::force_reload_log_level()  
685 -{  
686 - int ret = ERROR_SUCCESS;  
687 -  
688 - std::vector<ISrsReloadHandler*>::iterator it;  
689 -  
690 - for (it = subscribes.begin(); it != subscribes.end(); ++it) {  
691 - ISrsReloadHandler* subscribe = *it;  
692 - if ((ret = subscribe->on_reload_log_level()) != ERROR_SUCCESS) {  
693 - srs_error("notify subscribes reload srs_log_level failed. ret=%d", ret);  
694 - return ret;  
695 - }  
696 - }  
697 - srs_trace("reload srs_log_level success.");  
698 -  
699 - return ret;  
700 -}  
701 -  
702 int SrsConfig::reload_http_api(SrsConfDirective* old_root) 621 int SrsConfig::reload_http_api(SrsConfDirective* old_root)
703 { 622 {
704 int ret = ERROR_SUCCESS; 623 int ret = ERROR_SUCCESS;
@@ -143,18 +143,6 @@ public: @@ -143,18 +143,6 @@ public:
143 virtual int reload(); 143 virtual int reload();
144 private: 144 private:
145 virtual SrsConfDirective* get_or_create(SrsConfDirective* node, std::string name); 145 virtual SrsConfDirective* get_or_create(SrsConfDirective* node, std::string name);
146 -public:  
147 - /**  
148 - * dynamic set the config, for instance, for http api to set,  
149 - * @return ture if config changed and need to reload.  
150 - */  
151 - virtual bool set_log_file(std::string file);  
152 - virtual bool set_log_tank(std::string tank);  
153 - virtual bool set_log_level(std::string level);  
154 -public:  
155 - virtual int force_reload_log_file();  
156 - virtual int force_reload_log_tank();  
157 - virtual int force_reload_log_level();  
158 private: 146 private:
159 virtual int reload_http_api(SrsConfDirective* old_root); 147 virtual int reload_http_api(SrsConfDirective* old_root);
160 virtual int reload_http_stream(SrsConfDirective* old_root); 148 virtual int reload_http_stream(SrsConfDirective* old_root);
@@ -123,7 +123,6 @@ SrsApiV1::SrsApiV1() @@ -123,7 +123,6 @@ SrsApiV1::SrsApiV1()
123 handlers.push_back(new SrsApiSystemProcStats()); 123 handlers.push_back(new SrsApiSystemProcStats());
124 handlers.push_back(new SrsApiMemInfos()); 124 handlers.push_back(new SrsApiMemInfos());
125 handlers.push_back(new SrsApiAuthors()); 125 handlers.push_back(new SrsApiAuthors());
126 - handlers.push_back(new SrsApiConfigs());  
127 handlers.push_back(new SrsApiRequests()); 126 handlers.push_back(new SrsApiRequests());
128 } 127 }
129 128
@@ -149,7 +148,6 @@ int SrsApiV1::do_process_request(SrsSocket* skt, SrsHttpMessage* req) @@ -149,7 +148,6 @@ int SrsApiV1::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
149 << JFIELD_STR("self_proc_stats", "the self process stats") << JFIELD_CONT 148 << JFIELD_STR("self_proc_stats", "the self process stats") << JFIELD_CONT
150 << JFIELD_STR("system_proc_stats", "the system process stats") << JFIELD_CONT 149 << JFIELD_STR("system_proc_stats", "the system process stats") << JFIELD_CONT
151 << JFIELD_STR("meminfos", "the meminfo of system") << JFIELD_CONT 150 << JFIELD_STR("meminfos", "the meminfo of system") << JFIELD_CONT
152 - << JFIELD_STR("configs", "to query or modify the config of srs") << JFIELD_CONT  
153 << JFIELD_STR("authors", "the primary authors and contributors") << JFIELD_CONT 151 << JFIELD_STR("authors", "the primary authors and contributors") << JFIELD_CONT
154 << JFIELD_STR("requests", "the request itself, for http debug") 152 << JFIELD_STR("requests", "the request itself, for http debug")
155 << JOBJECT_END 153 << JOBJECT_END
@@ -222,120 +220,6 @@ int SrsApiRequests::do_process_request(SrsSocket* skt, SrsHttpMessage* req) @@ -222,120 +220,6 @@ int SrsApiRequests::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
222 return res_json(skt, req, ss.str()); 220 return res_json(skt, req, ss.str());
223 } 221 }
224 222
225 -SrsApiConfigs::SrsApiConfigs()  
226 -{  
227 - handlers.push_back(new SrsApiConfigsLogs());  
228 -}  
229 -  
230 -SrsApiConfigs::~SrsApiConfigs()  
231 -{  
232 -}  
233 -  
234 -bool SrsApiConfigs::can_handle(const char* path, int length, const char** /*pchild*/)  
235 -{  
236 - return srs_path_equals("/configs", path, length);  
237 -}  
238 -  
239 -int SrsApiConfigs::do_process_request(SrsSocket* skt, SrsHttpMessage* req)  
240 -{  
241 - std::stringstream ss;  
242 -  
243 - ss << JOBJECT_START  
244 - << JFIELD_ERROR(ERROR_SUCCESS) << JFIELD_CONT  
245 - << JFIELD_ORG("urls", JOBJECT_START)  
246 - << JFIELD_NAME("logs") << JOBJECT_START  
247 - << JFIELD_STR("uri", req->uri()+"/logs") << JFIELD_CONT  
248 - << JFIELD_STR("desc", "system log settings") << JFIELD_CONT  
249 - << JFIELD_STR("GET", "query logs tank/level/file") << JFIELD_CONT  
250 - << JFIELD_STR("PUT", "update logs tank/level/file")  
251 - << JOBJECT_END  
252 - << JOBJECT_END  
253 - << JOBJECT_END;  
254 -  
255 - return res_json(skt, req, ss.str());  
256 -}  
257 -  
258 -SrsApiConfigsLogs::SrsApiConfigsLogs()  
259 -{  
260 -}  
261 -  
262 -SrsApiConfigsLogs::~SrsApiConfigsLogs()  
263 -{  
264 -}  
265 -  
266 -bool SrsApiConfigsLogs::can_handle(const char* path, int length, const char** /*pchild*/)  
267 -{  
268 - return srs_path_equals("/logs", path, length);  
269 -}  
270 -  
271 -bool SrsApiConfigsLogs::is_handler_valid(SrsHttpMessage* req, int& status_code, string& reason_phrase)  
272 -{  
273 - if (!req->is_http_get() && !req->is_http_put()) {  
274 - status_code = HTTP_MethodNotAllowed;  
275 - reason_phrase = HTTP_MethodNotAllowed_str;  
276 -  
277 - return false;  
278 - }  
279 -  
280 - return SrsHttpHandler::is_handler_valid(req, status_code, reason_phrase);  
281 -}  
282 -  
283 -int SrsApiConfigsLogs::do_process_request(SrsSocket* skt, SrsHttpMessage* req)  
284 -{  
285 - int ret = ERROR_SUCCESS;  
286 -  
287 - // HTTP GET  
288 - if (req->is_http_get()) {  
289 - std::stringstream ss;  
290 - ss << JOBJECT_START  
291 - << JFIELD_ERROR(ERROR_SUCCESS) << JFIELD_CONT  
292 - << JFIELD_ORG("data", JOBJECT_START)  
293 - << JFIELD_STR("tank", (_srs_config->get_log_tank_file()? "file":"console")) << JFIELD_CONT  
294 - << JFIELD_STR("level", _srs_config->get_log_level()) << JFIELD_CONT  
295 - << JFIELD_STR("cwd", _srs_config->cwd()) << JFIELD_CONT  
296 - << JFIELD_STR("file", _srs_config->get_log_file())  
297 - << JOBJECT_END  
298 - << JOBJECT_END;  
299 -  
300 - return res_json(skt, req, ss.str());  
301 - }  
302 -  
303 - // HTTP PUT  
304 - srs_trace("http api PUT logs, req is: %s", req->body().c_str());  
305 -  
306 - SrsJsonAny* json = SrsJsonAny::loads(req->body_raw());  
307 - SrsAutoFree(SrsJsonAny, json);  
308 -  
309 - if (!json) {  
310 - return response_error(skt, req, ERROR_HTTP_API_LOGS, "invalid PUT json");  
311 - } else if (!json->is_object()) {  
312 - return response_error(skt, req, ERROR_HTTP_API_LOGS, "invalid PUT json logs params");  
313 - }  
314 -  
315 - SrsJsonObject* o = json->to_object();  
316 - SrsJsonAny* prop = NULL;  
317 - if ((prop = o->ensure_property_string("file")) != NULL && _srs_config->set_log_file(prop->to_str())) {  
318 - if ((ret = _srs_config->force_reload_log_file()) != ERROR_SUCCESS) {  
319 - return response_error(skt, req, ret, "reload log file failed");  
320 - }  
321 - srs_warn("http api reload log file to %s", prop->to_str().c_str());  
322 - }  
323 - if ((prop = o->ensure_property_string("tank")) != NULL && _srs_config->set_log_tank(prop->to_str())) {  
324 - if ((ret = _srs_config->force_reload_log_tank()) != ERROR_SUCCESS) {  
325 - return response_error(skt, req, ret, "reload log tank failed");  
326 - }  
327 - srs_warn("http api reload log tank to %s", prop->to_str().c_str());  
328 - }  
329 - if ((prop = o->ensure_property_string("level")) != NULL && _srs_config->set_log_level(prop->to_str())) {  
330 - if ((ret = _srs_config->force_reload_log_level()) != ERROR_SUCCESS) {  
331 - return response_error(skt, req, ret, "reload log level failed");  
332 - }  
333 - srs_warn("http api reload log level to %s", prop->to_str().c_str());  
334 - }  
335 -  
336 - return response_error(skt, req, ret, "PUT logs success.");  
337 -}  
338 -  
339 SrsApiVersion::SrsApiVersion() 223 SrsApiVersion::SrsApiVersion()
340 { 224 {
341 } 225 }
@@ -87,29 +87,6 @@ protected: @@ -87,29 +87,6 @@ protected:
87 virtual int do_process_request(SrsSocket* skt, SrsHttpMessage* req); 87 virtual int do_process_request(SrsSocket* skt, SrsHttpMessage* req);
88 }; 88 };
89 89
90 -class SrsApiConfigs : public SrsHttpHandler  
91 -{  
92 -public:  
93 - SrsApiConfigs();  
94 - virtual ~SrsApiConfigs();  
95 -public:  
96 - virtual bool can_handle(const char* path, int length, const char** pchild);  
97 -protected:  
98 - virtual int do_process_request(SrsSocket* skt, SrsHttpMessage* req);  
99 -};  
100 -  
101 -class SrsApiConfigsLogs : public SrsHttpHandler  
102 -{  
103 -public:  
104 - SrsApiConfigsLogs();  
105 - virtual ~SrsApiConfigsLogs();  
106 -public:  
107 - virtual bool can_handle(const char* path, int length, const char** pchild);  
108 -protected:  
109 - virtual bool is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase);  
110 - virtual int do_process_request(SrsSocket* skt, SrsHttpMessage* req);  
111 -};  
112 -  
113 class SrsApiVersion : public SrsHttpHandler 90 class SrsApiVersion : public SrsHttpHandler
114 { 91 {
115 public: 92 public:
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "147" 34 +#define VERSION_REVISION "148"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"