From 80ddf018d9d086acd73511773a269c2defbdfd95 Mon Sep 17 00:00:00 2001 From: monktan Date: Tue, 17 Nov 2020 14:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89serverid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/main.cpp b/server/main.cpp index 705092c4..43a9703a 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -146,6 +146,14 @@ public: false,/*该选项是否必须赋值,如果没有默认值且为ArgRequired时用户必须提供该参数否则将抛异常*/ "启动事件触发线程数",/*该选项说明文字*/ nullptr); + + (*_parser) << Option('i',/*该选项简称,如果是\x00则说明无简称*/ + "mserverid",/*该选项全称,每个选项必须有全称;不得为null或空字符串*/ + Option::ArgRequired,/*该选项后面必须跟值*/ + "",/*该选项默认值*/ + false,/*该选项是否必须赋值,如果没有默认值且为ArgRequired时用户必须提供该参数否则将抛异常*/ + "MediaServerId自定义值",/*该选项说明文字*/ + nullptr); } virtual ~CMD_main() {} @@ -212,6 +220,7 @@ int start_main(int argc,char *argv[]) { g_ini_file = cmd_main["config"]; string ssl_file = cmd_main["ssl"]; int threads = cmd_main["threads"]; + std::string mid = cmd_main["mserverid"]; //设置日志 Logger::Instance().add(std::make_shared("ConsoleChannel", logLevel)); @@ -237,6 +246,11 @@ int start_main(int argc,char *argv[]) { //加载配置文件,如果配置文件不存在就创建一个 loadIniConfig(g_ini_file.data()); + //如果自定义了mediaserverid,在这里覆盖配置文件 + if(!mid.empty()) { + mINI::Instance()[General::kMediaServerId] = mid; + } + if(!File::is_dir(ssl_file.data())){ //不是文件夹,加载证书,证书包含公钥和私钥 SSL_Initor::Instance().loadCertificate(ssl_file.data());