80 std::string configService;
83 if (vm.count(
"help") || vm.count(
"version"))
88 #if PLATFORM == PLATFORM_WINDOWS
89 if (configService.compare(
"install") == 0)
90 return WinServiceInstall() ? 0 : 1;
91 else if (configService.compare(
"uninstall") == 0)
92 return WinServiceUninstall() ? 0 : 1;
93 else if (configService.compare(
"run") == 0)
94 return WinServiceRun() ? 0 : 1;
97 std::string configError;
98 if (!
sConfigMgr->LoadInitial(configFile, configError))
100 printf(
"Error in config file: %s\n", configError.c_str());
105 sLog->Initialize(
nullptr);
108 TC_LOG_INFO(
"server.bnetserver",
"<Ctrl-C> to stop.\n");
109 TC_LOG_INFO(
"server.bnetserver",
"Using configuration file %s.", configFile.c_str());
110 TC_LOG_INFO(
"server.bnetserver",
"Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
111 TC_LOG_INFO(
"server.bnetserver",
"Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
119 std::string pidFile =
sConfigMgr->GetStringDefault(
"PidFile",
"");
120 if (!pidFile.empty())
123 TC_LOG_INFO(
"server.bnetserver",
"Daemon PID: %u\n", pid);
126 TC_LOG_ERROR(
"server.bnetserver",
"Cannot create PID file %s.\n", pidFile.c_str());
133 TC_LOG_ERROR(
"server.bnetserver",
"Failed to initialize SSL context");
145 if (bnport < 0 || bnport > 0xFFFF)
147 TC_LOG_ERROR(
"server.bnetserver",
"Specified battle.net port (%d) out of allowed range (1-65535)", bnport);
157 TC_LOG_ERROR(
"server.bnetserver",
"Failed to initialize login service");
164 std::string bindIp =
sConfigMgr->GetStringDefault(
"BindIP",
"0.0.0.0");
169 boost::asio::signal_set signals(*
_ioService, SIGINT, SIGTERM);
170 #if PLATFORM == PLATFORM_WINDOWS
171 signals.add(SIGBREAK);
189 #if PLATFORM == PLATFORM_WINDOWS
213 TC_LOG_INFO(
"server.bnetserver",
"Halting process...");
Definition: BigNumber.h:28
#define sSessionMgr
Definition: SessionManager.h:43
static boost::asio::io_service * _ioService
Definition: Main.cpp:69
static bool Initialize()
Definition: SslContext.cpp:21
uint32 CreatePIDFile(std::string const &filename)
create PID file
Definition: Util.cpp:222
void StopDB()
Close the connection to the database.
Definition: Main.cpp:243
variables_map GetConsoleArguments(int argc, char **argv, std::string &configFile, std::string &configService)
Definition: Main.cpp:298
#define sConfigMgr
Definition: Config.h:61
void BanExpiryHandler(boost::system::error_code const &error)
Definition: Main.cpp:267
TC_COMMON_API char const * GetFullVersion()
Definition: GitRevision.cpp:51
#define sLog
Definition: Log.h:154
int m_ServiceStatus
Definition: Main.cpp:56
#define _TRINITY_BNET_CONFIG
Definition: Main.cpp:42
void KeepDatabaseAliveHandler(boost::system::error_code const &error)
Definition: Main.cpp:255
float seconds()
Definition: units.h:97
static boost::asio::deadline_timer * _serviceStatusWatchTimer
Definition: Main.cpp:58
#define GOOGLE_PROTOBUF_VERIFY_VERSION
Definition: common.h:149
void SignalHandler(boost::system::error_code const &error, int signalNumber)
Definition: Main.cpp:249
float minutes()
Definition: units.h:102
LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary()
static boost::asio::deadline_timer * _dbPingTimer
Definition: Main.cpp:70
int32_t int32
Definition: Define.h:146
void AbortHandler(int)
Definition: Errors.cpp:99
uint32_t uint32
Definition: Define.h:150
static uint32 _dbPingInterval
Definition: Main.cpp:71
void SetRand(int32 numbits)
Definition: BigNumber.cpp:74
void ServiceStatusWatcher(boost::system::error_code const &error)
Definition: Main.cpp:280
bool StartDB()
Initialize connection to the database.
Definition: Main.cpp:225
static boost::asio::deadline_timer * _banExpiryCheckTimer
Definition: Main.cpp:72
#define sRealmList
Definition: RealmList.h:101
Definition: AppenderDB.h:23
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sLoginService
Definition: LoginRESTService.h:108
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetProcessPriority(const std::string &logChannel)
Definition: ProcessPriority.h:29
static uint32 _banExpiryCheckInterval
Definition: Main.cpp:73
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083