diff options
Diffstat (limited to 'src/trinityrealm/Main.cpp')
-rw-r--r-- | src/trinityrealm/Main.cpp | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/src/trinityrealm/Main.cpp b/src/trinityrealm/Main.cpp index 05fd704c10b..65596e35b21 100644 --- a/src/trinityrealm/Main.cpp +++ b/src/trinityrealm/Main.cpp @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,6 @@ #include "sockets/ListenSocket.h" #include "AuthSocket.h" #include "SystemConfig.h" -#include "revision.h" #include "Util.h" // Format is YYYYMMDDRR where RR is the change in the conf file @@ -41,12 +40,12 @@ #endif #ifndef _TRINITY_REALM_CONFIG -# define _TRINITY_REALM_CONFIG "trinityrealm.conf" +# define _TRINITY_REALM_CONFIG "TrinityRealm.conf" #endif //_TRINITY_REALM_CONFIG #ifdef WIN32 #include "ServiceWin32.h" -char serviceName[] = "realmd"; +char serviceName[] = "TrinityRealm"; char serviceLongName[] = "Trinity realm service"; char serviceDescription[] = "Massive Network Game Object Server"; /* @@ -58,7 +57,7 @@ char serviceDescription[] = "Massive Network Game Object Server"; int m_ServiceStatus = -1; #endif -bool StartDB(std::string &dbstring); +bool StartDB(); void UnhookSignals(); void HookSignals(); @@ -71,7 +70,6 @@ DatabaseType LoginDatabase; ///< Accessor to the void usage(const char *prog) { sLog.outString("Usage: \n %s [<options>]\n" - " --version print version and exit\n\r" " -c config_file use config_file as configuration file\n\r" #ifdef WIN32 " Running as service functions:\n\r" @@ -102,12 +100,6 @@ extern int main(int argc, char **argv) cfg_file = argv[c]; } - if( strcmp(argv[c],"--version") == 0) - { - printf("%s\n", _FULLVERSION); - return 0; - } - #ifdef WIN32 //////////// //Services// @@ -187,10 +179,19 @@ extern int main(int argc, char **argv) } ///- Initialize the database connection - std::string dbstring; - if(!StartDB(dbstring)) + if(!StartDB()) return 1; + ///- Initialize the log database + if(sConfig.GetBoolDefault("EnableLogDB", false)) + { + // everything successful - set var to enable DB logging once startup finished. + sLog.SetLogDBLater(true); + sLog.SetLogDB(false); + // ensure we've set realm to 0 (realmd realmid) + sLog.SetRealmID(0); + } + ///- Get the list of realms for the server m_realmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); if (m_realmList.size() == 0) @@ -243,7 +244,7 @@ extern int main(int argc, char **argv) sLog.outError("Can't set used processors (hex): %x", curAff); } } - sLog.outString(); + sLog.outString(""); } bool Prio = sConfig.GetBoolDefault("ProcessPriority", false); @@ -254,7 +255,7 @@ extern int main(int argc, char **argv) sLog.outString("TrinityRealm process priority class set to HIGH"); else sLog.outError("ERROR: Can't set realmd process priority class."); - sLog.outString(); + sLog.outString(""); } } #endif @@ -263,6 +264,20 @@ extern int main(int argc, char **argv) uint32 numLoops = (sConfig.GetIntDefault( "MaxPingTime", 30 ) * (MINUTE * 1000000 / 100000)); uint32 loopCounter = 0; + // possibly enable db logging; avoid massive startup spam by doing it here. + if (sLog.GetLogDBLater()) + { + sLog.outString("Enabling database logging..."); + sLog.SetLogDBLater(false); + // login db needs thread for logging + sLog.SetLogDB(true); + } + else + { + sLog.SetLogDB(false); + sLog.SetLogDBLater(false); + } + ///- Wait for termination signal while (!stopEvent) { @@ -282,6 +297,7 @@ extern int main(int argc, char **argv) } ///- Wait for the delay thread to exit + LoginDatabase.ThreadEnd(); LoginDatabase.HaltDelayThread(); ///- Remove signal handling before leaving @@ -312,20 +328,21 @@ void OnSignal(int s) } /// Initialize connection to the database -bool StartDB(std::string &dbstring) +bool StartDB() { - if(!sConfig.GetString("LoginDatabaseInfo", &dbstring)) + std::string dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); + if(dbstring.empty()) { sLog.outError("Database not specified"); return false; } - sLog.outString("Database: %s", dbstring.c_str() ); if(!LoginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to database"); return false; } + LoginDatabase.ThreadStart(); return true; } @@ -351,4 +368,3 @@ void UnhookSignals() } /// @} - |