mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11500] Allow run mangos as daemon (linux/other posix)
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
b022e398b7
commit
d00592f692
7 changed files with 238 additions and 28 deletions
|
|
@ -46,6 +46,8 @@ char serviceDescription[] = "Massive Network Game Object Server";
|
|||
* 2 - paused
|
||||
*/
|
||||
int m_ServiceStatus = -1;
|
||||
#else
|
||||
#include "PosixDaemon.h"
|
||||
#endif
|
||||
|
||||
DatabaseType WorldDatabase; ///< Accessor to the world database
|
||||
|
|
@ -65,6 +67,10 @@ void usage(const char *prog)
|
|||
" -s run run as service\n\r"
|
||||
" -s install install service\n\r"
|
||||
" -s uninstall uninstall service\n\r"
|
||||
#else
|
||||
" Running as daemon functions:\n\r"
|
||||
" -s run run as daemon\n\r"
|
||||
" -s stop stop daemon\n\r"
|
||||
#endif
|
||||
,prog);
|
||||
}
|
||||
|
|
@ -75,15 +81,19 @@ extern int main(int argc, char **argv)
|
|||
///- Command line parsing
|
||||
char const* cfg_file = _MANGOSD_CONFIG;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
char const *options = ":c:s:";
|
||||
#else
|
||||
char const *options = ":c:";
|
||||
#endif
|
||||
|
||||
ACE_Get_Opt cmd_opts(argc, argv, options);
|
||||
cmd_opts.long_option("version", 'v');
|
||||
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int option;
|
||||
while ((option = cmd_opts()) != EOF)
|
||||
{
|
||||
|
|
@ -95,9 +105,9 @@ extern int main(int argc, char **argv)
|
|||
case 'v':
|
||||
printf("%s\n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID));
|
||||
return 0;
|
||||
#ifdef WIN32
|
||||
case 's':
|
||||
{
|
||||
{
|
||||
#ifdef WIN32
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
|
||||
if (!strcmp(mode, "install"))
|
||||
|
|
@ -122,8 +132,22 @@ extern int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
if (!strcmp(mode, "run"))
|
||||
startDaemon(120);
|
||||
else if (!strcmp(mode, "stop"))
|
||||
stopDaemon();
|
||||
else
|
||||
{
|
||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
||||
usage(argv[0]);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt());
|
||||
usage(argv[0]);
|
||||
|
|
@ -137,13 +161,6 @@ extern int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
|
||||
sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) );
|
||||
sLog.outString( "<Ctrl-C> to stop.\n\n" );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue