mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
parent
c530f281c3
commit
2771bc15a5
@ -168,6 +168,8 @@ on_stream_none_reader=https://127.0.0.1/index/hook/on_stream_none_reader
|
|||||||
on_stream_not_found=https://127.0.0.1/index/hook/on_stream_not_found
|
on_stream_not_found=https://127.0.0.1/index/hook/on_stream_not_found
|
||||||
#服务器启动报告,可以用于服务器的崩溃重启事件监听
|
#服务器启动报告,可以用于服务器的崩溃重启事件监听
|
||||||
on_server_started=https://127.0.0.1/index/hook/on_server_started
|
on_server_started=https://127.0.0.1/index/hook/on_server_started
|
||||||
|
#服务器退出报告,当服务器正常退出时触发
|
||||||
|
on_server_exited=https://127.0.0.1/index/hook/on_server_exited
|
||||||
#server保活上报
|
#server保活上报
|
||||||
on_server_keepalive=https://127.0.0.1/index/hook/on_server_keepalive
|
on_server_keepalive=https://127.0.0.1/index/hook/on_server_keepalive
|
||||||
#发送rtp(startSendRtp)被动关闭时回调
|
#发送rtp(startSendRtp)被动关闭时回调
|
||||||
|
@ -44,6 +44,7 @@ const string kOnShellLogin = HOOK_FIELD "on_shell_login";
|
|||||||
const string kOnStreamNoneReader = HOOK_FIELD "on_stream_none_reader";
|
const string kOnStreamNoneReader = HOOK_FIELD "on_stream_none_reader";
|
||||||
const string kOnHttpAccess = HOOK_FIELD "on_http_access";
|
const string kOnHttpAccess = HOOK_FIELD "on_http_access";
|
||||||
const string kOnServerStarted = HOOK_FIELD "on_server_started";
|
const string kOnServerStarted = HOOK_FIELD "on_server_started";
|
||||||
|
const string kOnServerExited = HOOK_FIELD "on_server_exited";
|
||||||
const string kOnServerKeepalive = HOOK_FIELD "on_server_keepalive";
|
const string kOnServerKeepalive = HOOK_FIELD "on_server_keepalive";
|
||||||
const string kOnSendRtpStopped = HOOK_FIELD "on_send_rtp_stopped";
|
const string kOnSendRtpStopped = HOOK_FIELD "on_send_rtp_stopped";
|
||||||
const string kOnRtpServerTimeout = HOOK_FIELD "on_rtp_server_timeout";
|
const string kOnRtpServerTimeout = HOOK_FIELD "on_rtp_server_timeout";
|
||||||
@ -69,6 +70,7 @@ static onceToken token([]() {
|
|||||||
mINI::Instance()[kOnStreamNoneReader] = "";
|
mINI::Instance()[kOnStreamNoneReader] = "";
|
||||||
mINI::Instance()[kOnHttpAccess] = "";
|
mINI::Instance()[kOnHttpAccess] = "";
|
||||||
mINI::Instance()[kOnServerStarted] = "";
|
mINI::Instance()[kOnServerStarted] = "";
|
||||||
|
mINI::Instance()[kOnServerExited] = "";
|
||||||
mINI::Instance()[kOnServerKeepalive] = "";
|
mINI::Instance()[kOnServerKeepalive] = "";
|
||||||
mINI::Instance()[kOnSendRtpStopped] = "";
|
mINI::Instance()[kOnSendRtpStopped] = "";
|
||||||
mINI::Instance()[kOnRtpServerTimeout] = "";
|
mINI::Instance()[kOnRtpServerTimeout] = "";
|
||||||
@ -238,6 +240,18 @@ static void reportServerStarted() {
|
|||||||
do_http_hook(hook_server_started, body, nullptr);
|
do_http_hook(hook_server_started, body, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reportServerExited() {
|
||||||
|
GET_CONFIG(bool, hook_enable, Hook::kEnable);
|
||||||
|
GET_CONFIG(string, hook_server_exited, Hook::kOnServerExited);
|
||||||
|
if (!hook_enable || hook_server_exited.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ArgsType body;
|
||||||
|
// 执行hook
|
||||||
|
do_http_hook(hook_server_exited, body, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// 服务器定时保活定时器
|
// 服务器定时保活定时器
|
||||||
static Timer::Ptr g_keepalive_timer;
|
static Timer::Ptr g_keepalive_timer;
|
||||||
static void reportServerKeepalive() {
|
static void reportServerKeepalive() {
|
||||||
@ -668,3 +682,7 @@ void unInstallWebHook() {
|
|||||||
g_keepalive_timer.reset();
|
g_keepalive_timer.reset();
|
||||||
NoticeCenter::Instance().delListener(&web_hook_tag);
|
NoticeCenter::Instance().delListener(&web_hook_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onProcessExited() {
|
||||||
|
reportServerExited();
|
||||||
|
}
|
@ -31,6 +31,7 @@ extern const std::string kTimeoutSec;
|
|||||||
|
|
||||||
void installWebHook();
|
void installWebHook();
|
||||||
void unInstallWebHook();
|
void unInstallWebHook();
|
||||||
|
void onProcessExited();
|
||||||
/**
|
/**
|
||||||
* 触发http hook请求
|
* 触发http hook请求
|
||||||
* @param url 请求地址
|
* @param url 请求地址
|
||||||
|
@ -409,9 +409,9 @@ int start_main(int argc,char *argv[]) {
|
|||||||
static semaphore sem;
|
static semaphore sem;
|
||||||
signal(SIGINT, [](int) {
|
signal(SIGINT, [](int) {
|
||||||
InfoL << "SIGINT:exit";
|
InfoL << "SIGINT:exit";
|
||||||
signal(SIGINT, SIG_IGN);// 设置退出信号
|
signal(SIGINT, SIG_IGN); // 设置退出信号
|
||||||
sem.post();
|
sem.post();
|
||||||
});// 设置退出信号
|
}); // 设置退出信号
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
signal(SIGHUP, [](int) { mediakit::loadIniConfig(g_ini_file.data()); });
|
signal(SIGHUP, [](int) { mediakit::loadIniConfig(g_ini_file.data()); });
|
||||||
@ -420,6 +420,8 @@ int start_main(int argc,char *argv[]) {
|
|||||||
}
|
}
|
||||||
unInstallWebApi();
|
unInstallWebApi();
|
||||||
unInstallWebHook();
|
unInstallWebHook();
|
||||||
|
onProcessExited();
|
||||||
|
|
||||||
//休眠1秒再退出,防止资源释放顺序错误
|
//休眠1秒再退出,防止资源释放顺序错误
|
||||||
InfoL << "程序退出中,请等待...";
|
InfoL << "程序退出中,请等待...";
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user