From 365c864a587365fe443b11cc0cd7cfc8f8f8eb81 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期二, 01 六月 2021 11:19:22 +0800
Subject: [PATCH] refactor, clean up useless code.
---
box/center_main.cc | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/box/center_main.cc b/box/center_main.cc
index 6795e41..e7715f8 100644
--- a/box/center_main.cc
+++ b/box/center_main.cc
@@ -83,12 +83,6 @@
std::atomic<bool> run_;
};
-bool CenterInit(bhome_shm::SharedMemory &shm)
-{
- ShmSocket create(shm, BHGlobalSenderAddress(), 16);
- return true;
-}
-
} // namespace
int center_main(int argc, const char *argv[])
{
@@ -98,7 +92,7 @@
return 0;
}
- ns_log::AddLog("/tmp/bhshmq_center.log");
+ ns_log::AddLog(BHLogDir() + "bhshmq_center.log");
auto lvl = args.Get("log", "info");
if (strcasecmp(lvl.c_str(), "trace") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::trace); }
if (strcasecmp(lvl.c_str(), "debug") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::debug); }
@@ -108,12 +102,19 @@
if (strcasecmp(lvl.c_str(), "fatal") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::fatal); }
auto &shm = BHomeShm();
- CenterInit(shm);
+ if (!CenterInit(shm)) {
+ auto msg = "init memory error.";
+ LOG_FATAL() << msg;
+ printf("%s\n", msg);
+ exit(0);
+ }
GlobalInit(shm);
InstanceFlag inst(shm, kCenterRunningFlag);
if (!inst.TryStartAsFirstInstance()) {
- LOG_INFO() << "another instance is running, exit.";
+ auto msg = "another instance is running, exit.";
+ LOG_INFO() << msg;
+ printf("%s\n", msg);
return 0;
}
@@ -124,7 +125,9 @@
BHCenter center(shm);
center.Start();
- LOG_INFO() << "center started ...";
+ auto msg = "center started ...";
+ LOG_INFO() << msg;
+ printf("%s\n", msg);
WaitForSignals({SIGINT, SIGTERM});
center.Stop();
LOG_INFO() << "center stopped.";
--
Gitblit v1.8.0