| | |
| | | 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); } |
| | |
| | | if (strcasecmp(lvl.c_str(), "fatal") == 0) { ns_log::ResetLogLevel(ns_log::LogLevel::fatal); } |
| | | |
| | | auto &shm = BHomeShm(); |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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."; |