Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-07-05 13:02:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
95e73d0be1b4d17ba7103b9c9cc0b2fda315c6df
95e73d0b
1 parent
28a6a121
remove the config log http api. 0.9.148
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
22 行增加
和
254 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_http_api.hpp
trunk/src/core/srs_core.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
95e73d0
...
...
@@ -539,23 +539,38 @@ int SrsConfig::reload()
// merge config: srs_log_tank
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_tank"
),
old_root
->
get
(
"srs_log_tank"
)))
{
if
((
ret
=
force_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
return
ret
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_tank failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_tank success."
);
}
// merge config: srs_log_level
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_level"
),
old_root
->
get
(
"srs_log_level"
)))
{
if
((
ret
=
force_reload_log_level
())
!=
ERROR_SUCCESS
)
{
return
ret
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_level
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_level failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_level success."
);
}
// merge config: srs_log_file
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_file"
),
old_root
->
get
(
"srs_log_file"
)))
{
if
((
ret
=
force_reload_log_file
())
!=
ERROR_SUCCESS
)
{
return
ret
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_file
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_file failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_file success."
);
}
// merge config: pithy_print
...
...
@@ -603,102 +618,6 @@ SrsConfDirective* SrsConfig::get_or_create(SrsConfDirective* node, string name)
return
conf
;
}
bool
SrsConfig
::
set_log_file
(
string
file
)
{
if
(
file
==
get_log_file
())
{
return
false
;
}
SrsConfDirective
*
conf
=
get_or_create
(
root
,
"srs_log_file"
);
srs_assert
(
conf
);
conf
->
set_arg0
(
file
);
return
true
;
}
bool
SrsConfig
::
set_log_tank
(
string
tank
)
{
if
(
get_log_tank_file
()
&&
tank
!=
"console"
)
{
return
false
;
}
if
(
!
get_log_tank_file
()
&&
tank
==
"console"
)
{
return
false
;
}
SrsConfDirective
*
conf
=
get_or_create
(
root
,
"srs_log_tank"
);
srs_assert
(
conf
);
conf
->
set_arg0
(
tank
);
return
true
;
}
bool
SrsConfig
::
set_log_level
(
string
level
)
{
if
(
level
==
get_log_level
())
{
return
false
;
}
SrsConfDirective
*
conf
=
get_or_create
(
root
,
"srs_log_level"
);
srs_assert
(
conf
);
conf
->
set_arg0
(
level
);
return
true
;
}
int
SrsConfig
::
force_reload_log_file
()
{
int
ret
=
ERROR_SUCCESS
;
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_file
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_file failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_file success."
);
return
ret
;
}
int
SrsConfig
::
force_reload_log_tank
()
{
int
ret
=
ERROR_SUCCESS
;
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_tank failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_tank success."
);
return
ret
;
}
int
SrsConfig
::
force_reload_log_level
()
{
int
ret
=
ERROR_SUCCESS
;
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_level
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_level failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_level success."
);
return
ret
;
}
int
SrsConfig
::
reload_http_api
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
95e73d0
...
...
@@ -143,18 +143,6 @@ public:
virtual
int
reload
();
private
:
virtual
SrsConfDirective
*
get_or_create
(
SrsConfDirective
*
node
,
std
::
string
name
);
public
:
/**
* dynamic set the config, for instance, for http api to set,
* @return ture if config changed and need to reload.
*/
virtual
bool
set_log_file
(
std
::
string
file
);
virtual
bool
set_log_tank
(
std
::
string
tank
);
virtual
bool
set_log_level
(
std
::
string
level
);
public
:
virtual
int
force_reload_log_file
();
virtual
int
force_reload_log_tank
();
virtual
int
force_reload_log_level
();
private
:
virtual
int
reload_http_api
(
SrsConfDirective
*
old_root
);
virtual
int
reload_http_stream
(
SrsConfDirective
*
old_root
);
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
95e73d0
...
...
@@ -123,7 +123,6 @@ SrsApiV1::SrsApiV1()
handlers
.
push_back
(
new
SrsApiSystemProcStats
());
handlers
.
push_back
(
new
SrsApiMemInfos
());
handlers
.
push_back
(
new
SrsApiAuthors
());
handlers
.
push_back
(
new
SrsApiConfigs
());
handlers
.
push_back
(
new
SrsApiRequests
());
}
...
...
@@ -149,7 +148,6 @@ int SrsApiV1::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
<<
JFIELD_STR
(
"self_proc_stats"
,
"the self process stats"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"system_proc_stats"
,
"the system process stats"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"meminfos"
,
"the meminfo of system"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"configs"
,
"to query or modify the config of srs"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"authors"
,
"the primary authors and contributors"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"requests"
,
"the request itself, for http debug"
)
<<
JOBJECT_END
...
...
@@ -222,120 +220,6 @@ int SrsApiRequests::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
return
res_json
(
skt
,
req
,
ss
.
str
());
}
SrsApiConfigs
::
SrsApiConfigs
()
{
handlers
.
push_back
(
new
SrsApiConfigsLogs
());
}
SrsApiConfigs
::~
SrsApiConfigs
()
{
}
bool
SrsApiConfigs
::
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
/*pchild*/
)
{
return
srs_path_equals
(
"/configs"
,
path
,
length
);
}
int
SrsApiConfigs
::
do_process_request
(
SrsSocket
*
skt
,
SrsHttpMessage
*
req
)
{
std
::
stringstream
ss
;
ss
<<
JOBJECT_START
<<
JFIELD_ERROR
(
ERROR_SUCCESS
)
<<
JFIELD_CONT
<<
JFIELD_ORG
(
"urls"
,
JOBJECT_START
)
<<
JFIELD_NAME
(
"logs"
)
<<
JOBJECT_START
<<
JFIELD_STR
(
"uri"
,
req
->
uri
()
+
"/logs"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"desc"
,
"system log settings"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"GET"
,
"query logs tank/level/file"
)
<<
JFIELD_CONT
<<
JFIELD_STR
(
"PUT"
,
"update logs tank/level/file"
)
<<
JOBJECT_END
<<
JOBJECT_END
<<
JOBJECT_END
;
return
res_json
(
skt
,
req
,
ss
.
str
());
}
SrsApiConfigsLogs
::
SrsApiConfigsLogs
()
{
}
SrsApiConfigsLogs
::~
SrsApiConfigsLogs
()
{
}
bool
SrsApiConfigsLogs
::
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
/*pchild*/
)
{
return
srs_path_equals
(
"/logs"
,
path
,
length
);
}
bool
SrsApiConfigsLogs
::
is_handler_valid
(
SrsHttpMessage
*
req
,
int
&
status_code
,
string
&
reason_phrase
)
{
if
(
!
req
->
is_http_get
()
&&
!
req
->
is_http_put
())
{
status_code
=
HTTP_MethodNotAllowed
;
reason_phrase
=
HTTP_MethodNotAllowed_str
;
return
false
;
}
return
SrsHttpHandler
::
is_handler_valid
(
req
,
status_code
,
reason_phrase
);
}
int
SrsApiConfigsLogs
::
do_process_request
(
SrsSocket
*
skt
,
SrsHttpMessage
*
req
)
{
int
ret
=
ERROR_SUCCESS
;
// HTTP GET
if
(
req
->
is_http_get
())
{
std
::
stringstream
ss
;
ss
<<
JOBJECT_START
<<
JFIELD_ERROR
(
ERROR_SUCCESS
)
<<
JFIELD_CONT
<<
JFIELD_ORG
(
"data"
,
JOBJECT_START
)
<<
JFIELD_STR
(
"tank"
,
(
_srs_config
->
get_log_tank_file
()
?
"file"
:
"console"
))
<<
JFIELD_CONT
<<
JFIELD_STR
(
"level"
,
_srs_config
->
get_log_level
())
<<
JFIELD_CONT
<<
JFIELD_STR
(
"cwd"
,
_srs_config
->
cwd
())
<<
JFIELD_CONT
<<
JFIELD_STR
(
"file"
,
_srs_config
->
get_log_file
())
<<
JOBJECT_END
<<
JOBJECT_END
;
return
res_json
(
skt
,
req
,
ss
.
str
());
}
// HTTP PUT
srs_trace
(
"http api PUT logs, req is: %s"
,
req
->
body
().
c_str
());
SrsJsonAny
*
json
=
SrsJsonAny
::
loads
(
req
->
body_raw
());
SrsAutoFree
(
SrsJsonAny
,
json
);
if
(
!
json
)
{
return
response_error
(
skt
,
req
,
ERROR_HTTP_API_LOGS
,
"invalid PUT json"
);
}
else
if
(
!
json
->
is_object
())
{
return
response_error
(
skt
,
req
,
ERROR_HTTP_API_LOGS
,
"invalid PUT json logs params"
);
}
SrsJsonObject
*
o
=
json
->
to_object
();
SrsJsonAny
*
prop
=
NULL
;
if
((
prop
=
o
->
ensure_property_string
(
"file"
))
!=
NULL
&&
_srs_config
->
set_log_file
(
prop
->
to_str
()))
{
if
((
ret
=
_srs_config
->
force_reload_log_file
())
!=
ERROR_SUCCESS
)
{
return
response_error
(
skt
,
req
,
ret
,
"reload log file failed"
);
}
srs_warn
(
"http api reload log file to %s"
,
prop
->
to_str
().
c_str
());
}
if
((
prop
=
o
->
ensure_property_string
(
"tank"
))
!=
NULL
&&
_srs_config
->
set_log_tank
(
prop
->
to_str
()))
{
if
((
ret
=
_srs_config
->
force_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
return
response_error
(
skt
,
req
,
ret
,
"reload log tank failed"
);
}
srs_warn
(
"http api reload log tank to %s"
,
prop
->
to_str
().
c_str
());
}
if
((
prop
=
o
->
ensure_property_string
(
"level"
))
!=
NULL
&&
_srs_config
->
set_log_level
(
prop
->
to_str
()))
{
if
((
ret
=
_srs_config
->
force_reload_log_level
())
!=
ERROR_SUCCESS
)
{
return
response_error
(
skt
,
req
,
ret
,
"reload log level failed"
);
}
srs_warn
(
"http api reload log level to %s"
,
prop
->
to_str
().
c_str
());
}
return
response_error
(
skt
,
req
,
ret
,
"PUT logs success."
);
}
SrsApiVersion
::
SrsApiVersion
()
{
}
...
...
trunk/src/app/srs_app_http_api.hpp
查看文件 @
95e73d0
...
...
@@ -87,29 +87,6 @@ protected:
virtual
int
do_process_request
(
SrsSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsApiConfigs
:
public
SrsHttpHandler
{
public
:
SrsApiConfigs
();
virtual
~
SrsApiConfigs
();
public
:
virtual
bool
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
pchild
);
protected
:
virtual
int
do_process_request
(
SrsSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsApiConfigsLogs
:
public
SrsHttpHandler
{
public
:
SrsApiConfigsLogs
();
virtual
~
SrsApiConfigsLogs
();
public
:
virtual
bool
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
pchild
);
protected
:
virtual
bool
is_handler_valid
(
SrsHttpMessage
*
req
,
int
&
status_code
,
std
::
string
&
reason_phrase
);
virtual
int
do_process_request
(
SrsSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsApiVersion
:
public
SrsHttpHandler
{
public
:
...
...
trunk/src/core/srs_core.hpp
查看文件 @
95e73d0
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "14
7
"
#define VERSION_REVISION "14
8
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论