diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 31df7ae2..34e88147 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -190,6 +190,10 @@ bool checkArgs(Args &&args,First &&first,KeyTypes && ...keys){ throw InvalidArgs("缺少必要参数:" #__VA_ARGS__); \ } + +static unordered_map s_proxyMap; +static recursive_mutex s_proxyMapMtx; + //安装api接口 void installWebApi() { addHttpListener(); @@ -342,8 +346,6 @@ void installWebApi() { }); - static unordered_map s_proxyMap; - static recursive_mutex s_proxyMapMtx; API_REGIST(api,addStreamProxy,{ CHECK_ARGS("vhost","app","stream","url"); //添加拉流代理 @@ -424,6 +426,9 @@ void installWebApi() { val["msg"] = "success"; }); +} - +void unInstallWebApi(){ + lock_guard lck(s_proxyMapMtx); + s_proxyMap.clear(); } \ No newline at end of file diff --git a/server/WebHook.cpp b/server/WebHook.cpp index f5102b71..674f0198 100644 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -328,5 +328,8 @@ void installWebHook(){ }); #endif //ENABLE_MP4V2 +} + +void unInstallWebHook(){ } \ No newline at end of file diff --git a/server/main.cpp b/server/main.cpp index 6b52e0dc..92e4e055 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -153,7 +153,9 @@ public: extern void installWebApi(); +extern void unInstallWebApi(); extern void installWebHook(); +extern void unInstallWebHook(); static void inline listen_shell_input(){ cout << "> 欢迎进入命令模式,你可以输入\"help\"命令获取帮助" << endl; @@ -278,11 +280,18 @@ int main(int argc,char *argv[]) { static semaphore sem; signal(SIGINT, [](int) { InfoL << "SIGINT:exit"; + signal(SIGINT, SIG_IGN);// 设置退出信号 sem.post(); });// 设置退出信号 signal(SIGHUP, [](int) { mediakit::loadIniConfig(); }); sem.wait(); } + unInstallWebApi(); + unInstallWebHook(); + //休眠3秒再退出,防止资源释放顺序错误 + InfoL << "程序退出中,请等待..."; + sleep(3); + InfoL << "程序退出完毕!"; return 0; }