2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /// \addtogroup mangosd Mangos Daemon
24 #include "Database/DatabaseEnv.h"
25 #include "Config/ConfigEnv.h"
28 #include "SystemConfig.h"
30 #include "revision_nr.h"
31 #include <openssl/opensslv.h>
32 #include <openssl/crypto.h>
35 #include "ServiceWin32.h"
36 char serviceName
[] = "mangosd";
37 char serviceLongName
[] = "MaNGOS world service";
38 char serviceDescription
[] = "Massive Network Game Object Server";
40 * -1 - not in service mode
45 int m_ServiceStatus
= -1;
48 DatabaseType WorldDatabase
; ///< Accessor to the world database
49 DatabaseType CharacterDatabase
; ///< Accessor to the character database
50 DatabaseType loginDatabase
; ///< Accessor to the realm/login database
52 uint32 realmID
; ///< Id of the realm
54 /// Print out the usage string for this program on the console.
55 void usage(const char *prog
)
57 sLog
.outString("Usage: \n %s [<options>]\n"
58 " --version print version and exist\n\r"
59 " -c config_file use config_file as configuration file\n\r"
61 " Running as service functions:\n\r"
62 " --service run as service\n\r"
63 " -s install install service\n\r"
64 " -s uninstall uninstall service\n\r"
69 /// Launch the mangos server
70 extern int main(int argc
, char **argv
)
72 // - Construct Memory Manager Instance
73 MaNGOS::Singleton
<MemoryManager
>::Instance();
75 //char *leak = new char[1000]; // test leak detection
77 ///- Command line parsing to get the configuration file name
78 char const* cfg_file
= _MANGOSD_CONFIG
;
82 if( strcmp(argv
[c
],"-c") == 0)
86 sLog
.outError("Runtime-Error: -c option requires an input argument");
94 if( strcmp(argv
[c
],"--version") == 0)
96 printf("%s\n", _FULLVERSION(REVISION_DATE
,REVISION_TIME
,REVISION_NR
,REVISION_ID
));
104 if( strcmp(argv
[c
],"-s") == 0)
108 sLog
.outError("Runtime-Error: -s option requires an input argument");
112 if( strcmp(argv
[c
],"install") == 0)
114 if (WinServiceInstall())
115 sLog
.outString("Installing service");
118 else if( strcmp(argv
[c
],"uninstall") == 0)
120 if(WinServiceUninstall())
121 sLog
.outString("Uninstalling service");
126 sLog
.outError("Runtime-Error: unsupported option %s",argv
[c
]);
131 if( strcmp(argv
[c
],"--service") == 0)
140 if (!sConfig
.SetSource(cfg_file
))
142 sLog
.outError("Could not find configuration file %s.", cfg_file
);
146 sLog
.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE
,REVISION_TIME
,REVISION_NR
,REVISION_ID
) );
147 sLog
.outString( "<Ctrl-C> to stop.\n\n" );
149 sLog
.outTitle( "MM MM MM MM MMMMM MMMM MMMMM");
150 sLog
.outTitle( "MM MM MM MM MMM MMM MM MM MMM MMM");
151 sLog
.outTitle( "MMM MMM MMM MM MMM MMM MM MM MMM");
152 sLog
.outTitle( "MM M MM MMMM MM MMM MM MM MMM");
153 sLog
.outTitle( "MM M MM MMMMM MM MMMM MMM MM MM MMM");
154 sLog
.outTitle( "MM M MM M MMM MM MMM MMMMMMM MM MM MMM");
155 sLog
.outTitle( "MM MM MMM MM MM MM MMM MM MM MMM");
156 sLog
.outTitle( "MM MM MMMMMMM MM MM MMM MMM MM MM MMM MMM");
157 sLog
.outTitle( "MM MM MM MMM MM MM MMMMMM MMMM MMMMM");
158 sLog
.outTitle( " MM MMM http://getmangos.com");
159 sLog
.outTitle( " MMMMMM\n\n");
161 sLog
.outString("Using configuration file %s.", cfg_file
);
163 sLog
.outDetail("%s (Library: %s)", OPENSSL_VERSION_TEXT
, SSLeay_version(SSLEAY_VERSION
));
164 if (SSLeay() < 0x009080bfL
)
166 sLog
.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");
167 sLog
.outDetail("WARNING: Minimal required version [OpenSSL 0.9.8k]");
170 ///- and run the 'Master'
171 /// \todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd?
172 return sMaster
.Run();
174 // at sMaster return function exist with codes
175 // 0 - normal shutdown
176 // 1 - shutdown at error
177 // 2 - restart command used, this code can be used by restarter for restart mangosd