100 std::string configService;
104 if (vm.count(
"help") || vm.count(
"version"))
110 if (configService.compare(
"install") == 0)
111 return WinServiceInstall() ? 0 : 1;
112 else if (configService.compare(
"uninstall") == 0)
113 return WinServiceUninstall() ? 0 : 1;
114 else if (configService.compare(
"run") == 0)
115 return WinServiceRun() ? 0 : 0;
118 std::string configError;
119 if (!
sConfigMgr->LoadInitial(configFile, configError))
121 printf(
"Error in config file: %s\n", configError.c_str());
130 TC_LOG_INFO(
"server.worldserver",
"<Ctrl-C> to stop.\n");
132 TC_LOG_INFO(
"server.worldserver",
"/\\__ _\\ __ __/\\ \\__");
133 TC_LOG_INFO(
"server.worldserver",
"\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\, _\\ __ __");
134 TC_LOG_INFO(
"server.worldserver",
" \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\");
135 TC_LOG_INFO(
"server.worldserver",
" \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\");
136 TC_LOG_INFO(
"server.worldserver",
" \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\");
137 TC_LOG_INFO(
"server.worldserver",
" \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
138 TC_LOG_INFO(
"server.worldserver",
" C O R E /\\___/");
139 TC_LOG_INFO(
"server.worldserver",
"http://TrinityCore.org \\/__/\n");
140 TC_LOG_INFO(
"server.worldserver",
"Using configuration file %s.", configFile.c_str());
141 TC_LOG_INFO(
"server.worldserver",
"Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
142 TC_LOG_INFO(
"server.worldserver",
"Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
152 std::string pidFile =
sConfigMgr->GetStringDefault(
"PidFile",
"");
153 if (!pidFile.empty())
156 TC_LOG_INFO(
"server.worldserver",
"Daemon PID: %u\n", pid);
159 TC_LOG_ERROR(
"server.worldserver",
"Cannot create PID file %s.\n", pidFile.c_str());
165 boost::asio::signal_set signals(
_ioService, SIGINT, SIGTERM);
166 #if PLATFORM == PLATFORM_WINDOWS
167 signals.add(SIGBREAK);
172 int numThreads =
sConfigMgr->GetIntDefault(
"ThreadPool", 1);
173 std::vector<std::thread> threadPool;
178 for (
int i = 0; i < numThreads; ++i)
179 threadPool.push_back(std::thread(boost::bind(&boost::asio::io_service::run, &
_ioService)));
200 sWorld->SetInitialWorldSettings();
203 std::thread* cliThread =
nullptr;
207 if (
sConfigMgr->GetBoolDefault(
"Console.Enable",
true))
215 if (
sConfigMgr->GetBoolDefault(
"Ra.Enable",
false))
219 std::thread* soapThread =
nullptr;
220 if (
sConfigMgr->GetBoolDefault(
"SOAP.Enabled",
false))
227 std::string worldListener =
sConfigMgr->GetStringDefault(
"BindIP",
"0.0.0.0");
229 int networkThreads =
sConfigMgr->GetIntDefault(
"Network.Threads", 1);
231 if (networkThreads <= 0)
233 TC_LOG_ERROR(
"server.worldserver",
"Network.Threads must be greater than 0");
245 if (
int coreStuckTime =
sConfigMgr->GetIntDefault(
"MaxCoreStuckTime", 0))
250 TC_LOG_INFO(
"server.worldserver",
"Starting up anti-freeze thread (%u seconds max stuck time)...", coreStuckTime);
262 sLog->SetSynchronous();
267 sWorld->UpdateSessions(1);
284 if (soapThread !=
nullptr)
297 TC_LOG_INFO(
"server.worldserver",
"Halting process...");
Definition: BigNumber.h:28
uint32 Realm
Definition: Realm.h:53
Definition: AsyncAcceptor.h:28
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:105
uint32 CreatePIDFile(std::string const &filename)
create PID file
Definition: Util.cpp:222
Realm realm
Definition: World.cpp:3485
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
uint32 _maxCoreStuckTimeInMs(0)
void AddScripts()
Definition: ScriptLoader.cpp:37
boost::asio::deadline_timer _freezeCheckTimer(_ioService)
#define sWorldSocketMgr
Definition: WorldSocketMgr.h:62
#define sConfigMgr
Definition: Config.h:61
TC_COMMON_API char const * GetFullVersion()
Definition: GitRevision.cpp:51
void FreezeDetectorHandler(const boost::system::error_code &error)
Definition: Main.cpp:431
#define sLog
Definition: Log.h:154
int m_ServiceStatus
Definition: Main.cpp:56
#define sWorld
Definition: World.h:887
bool LoadRealmInfo()
Definition: Main.cpp:465
float seconds()
Definition: units.h:97
uint16_t uint16
Definition: g3dmath.h:166
AsyncAcceptor * StartRaSocketAcceptor(boost::asio::io_service &ioService)
Definition: Main.cpp:455
#define GOOGLE_PROTOBUF_VERIFY_VERSION
Definition: common.h:149
void SignalHandler(boost::system::error_code const &error, int signalNumber)
Definition: Main.cpp:249
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void ShutdownCLIThread(std::thread *cliThread)
Definition: Main.cpp:312
static uint8 GetExitCode()
Definition: World.h:661
void DirectPExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:134
void ClearOnlineAccounts()
Clear 'online' status for all accounts with characters in this realm.
Definition: Main.cpp:568
Battlenet::RealmHandle Id
Definition: Realm.h:86
LIBPROTOBUF_EXPORT void ShutdownProtobufLibrary()
void AbortHandler(int)
Definition: Errors.cpp:99
uint32_t uint32
Definition: Define.h:150
void CliThread()
Thread start
Definition: CliRunnable.cpp:133
uint16_t uint16
Definition: Define.h:151
void SetRand(int32 numbits)
Definition: BigNumber.cpp:74
boost::asio::io_service _ioService
Definition: Main.cpp:76
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:243
void ShutdownThreadPool(std::vector< std::thread > &threadPool)
Definition: Main.cpp:372
RealmFlags
Definition: Realm.h:27
bool StartDB()
Initialize connection to the database.
Definition: Main.cpp:225
#define sMapMgr
Definition: MapManager.h:194
#define sRealmList
Definition: RealmList.h:101
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
#define _TRINITY_CORE_CONFIG
Definition: Main.cpp:57
Definition: AppenderDB.h:23
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
void TCSoapThread(const std::string &host, uint16 port)
Definition: TCSoap.cpp:25
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
RealmFlags Flags
Definition: Realm.h:94
void WorldUpdateLoop()
Definition: Main.cpp:384
void SetProcessPriority(const std::string &logChannel)
Definition: ProcessPriority.h:29
TC_COMMON_API void threadsCleanup()
Needs to be called after threads using openssl are despawned.
Definition: OpenSSLCrypto.cpp:50
TC_COMMON_API void threadsSetup()
Needs to be called before threads using openssl are spawned.
Definition: OpenSSLCrypto.cpp:39
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083
float PopulationLevel
Definition: Realm.h:97