From 35c4c05e7b343a046aa8b826e220dd66f8b35ca9 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 4 Nov 2019 09:21:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsetServerConfig=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=9D=E5=AD=98=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9B=B8=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 2 +- server/WebApi.h | 2 ++ server/main.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 9a4fcdb7..453db5aa 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -347,7 +347,7 @@ void installWebApi() { } if (changed > 0) { NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig); - ini.dumpFile(); + ini.dumpFile(g_ini_file); } val["changed"] = changed; }); diff --git a/server/WebApi.h b/server/WebApi.h index c3ffecf1..2a917db3 100644 --- a/server/WebApi.h +++ b/server/WebApi.h @@ -47,5 +47,7 @@ extern const string kPort; void installWebApi(); void unInstallWebApi(); +//配置文件路径 +extern string g_ini_file; #endif //ZLMEDIAKIT_WEBAPI_H diff --git a/server/main.cpp b/server/main.cpp index fe583513..734baabe 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -205,6 +205,8 @@ static void inline listen_shell_input(){ } #endif//!defined(_WIN32) +//全局变量,在WebApi中用于保存配置文件用 +string g_ini_file; int start_main(int argc,char *argv[]) { { @@ -219,7 +221,7 @@ int start_main(int argc,char *argv[]) { bool bDaemon = cmd_main.hasKey("daemon"); LogLevel logLevel = (LogLevel) cmd_main["level"].as(); logLevel = MIN(MAX(logLevel, LTrace), LError); - static string ini_file = cmd_main["config"]; + g_ini_file = cmd_main["config"]; string ssl_file = cmd_main["ssl"]; int threads = cmd_main["threads"]; @@ -244,7 +246,7 @@ int start_main(int argc,char *argv[]) { //启动异步日志线程 Logger::Instance().setWriter(std::make_shared()); //加载配置文件,如果配置文件不存在就创建一个 - loadIniConfig(ini_file.data()); + loadIniConfig(g_ini_file.data()); //加载证书,证书包含公钥和私钥 SSL_Initor::Instance().loadCertificate(ssl_file.data()); @@ -306,7 +308,7 @@ int start_main(int argc,char *argv[]) { });// 设置退出信号 #if !defined(_WIN32) - signal(SIGHUP, [](int) { mediakit::loadIniConfig(ini_file.data()); }); + signal(SIGHUP, [](int) { mediakit::loadIniConfig(g_ini_file.data()); }); #endif sem.wait(); }