mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[11507] Fixed problem with too later config read in recent added posix daemon support.
Restore read config _after_ option parsing in any cases.
This commit is contained in:
parent
945466934d
commit
6ed4dfe827
3 changed files with 79 additions and 77 deletions
|
|
@ -87,14 +87,7 @@ extern int main(int argc, char **argv)
|
|||
ACE_Get_Opt cmd_opts(argc, argv, options);
|
||||
cmd_opts.long_option("version", 'v');
|
||||
|
||||
#ifndef WIN32 // need call before options for posix daemon
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
char serviceDaemonMode = '\0';
|
||||
|
||||
int option;
|
||||
while ((option = cmd_opts()) != EOF)
|
||||
|
|
@ -109,37 +102,19 @@ extern int main(int argc, char **argv)
|
|||
return 0;
|
||||
case 's':
|
||||
{
|
||||
#ifdef WIN32
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
|
||||
if (!strcmp(mode, "install"))
|
||||
{
|
||||
if (WinServiceInstall())
|
||||
sLog.outString("Installing service");
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(mode, "uninstall"))
|
||||
{
|
||||
if (WinServiceUninstall())
|
||||
sLog.outString("Uninstalling service");
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(mode, "run"))
|
||||
WinServiceRun();
|
||||
else
|
||||
{
|
||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
||||
usage(argv[0]);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
#else
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
if (!strcmp(mode, "run"))
|
||||
startDaemon(120);
|
||||
serviceDaemonMode = 'r';
|
||||
#ifdef WIN32
|
||||
else if (!strcmp(mode, "install"))
|
||||
serviceDaemonMode = 'i';
|
||||
else if (!strcmp(mode, "uninstall"))
|
||||
serviceDaemonMode = 'u';
|
||||
#else
|
||||
else if (!strcmp(mode, "stop"))
|
||||
stopDaemon();
|
||||
serviceDaemonMode = 's';
|
||||
#endif
|
||||
else
|
||||
{
|
||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
||||
|
|
@ -147,9 +122,8 @@ extern int main(int argc, char **argv)
|
|||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ':':
|
||||
sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt());
|
||||
usage(argv[0]);
|
||||
|
|
@ -163,13 +137,40 @@ extern int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32 // need call after options for windows service
|
||||
#ifndef WIN32 // posix daemon commands need apply before config read
|
||||
switch (serviceDaemonMode)
|
||||
{
|
||||
case 'r':
|
||||
startDaemon();
|
||||
break;
|
||||
case 's':
|
||||
stopDaemon();
|
||||
break
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WIN32 // windows service command need execute after config read
|
||||
switch (serviceDaemonMode)
|
||||
{
|
||||
case 'i':
|
||||
if (WinServiceInstall())
|
||||
sLog.outString("Installing service");
|
||||
return 1;
|
||||
case 'u':
|
||||
if (WinServiceUninstall())
|
||||
sLog.outString("Uninstalling service");
|
||||
return 1;
|
||||
case 'r':
|
||||
WinServiceRun();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) );
|
||||
|
|
|
|||
|
|
@ -96,17 +96,9 @@ extern int main(int argc, char **argv)
|
|||
ACE_Get_Opt cmd_opts(argc, argv, options);
|
||||
cmd_opts.long_option("version", 'v');
|
||||
|
||||
#ifndef WIN32 // need call before options for posix daemon
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
char serviceDaemonMode = '\0';
|
||||
|
||||
int option;
|
||||
|
||||
while ((option = cmd_opts()) != EOF)
|
||||
{
|
||||
switch (option)
|
||||
|
|
@ -120,36 +112,19 @@ extern int main(int argc, char **argv)
|
|||
|
||||
case 's':
|
||||
{
|
||||
#ifdef WIN32
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
|
||||
if (!strcmp(mode, "install"))
|
||||
{
|
||||
if (WinServiceInstall())
|
||||
sLog.outString("Installing service");
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(mode, "uninstall"))
|
||||
{
|
||||
if (WinServiceUninstall())
|
||||
sLog.outString("Uninstalling service");
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp(mode, "run"))
|
||||
WinServiceRun();
|
||||
else
|
||||
{
|
||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
||||
usage(argv[0]);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
const char *mode = cmd_opts.opt_arg();
|
||||
if (!strcmp(mode, "run"))
|
||||
startDaemon();
|
||||
serviceDaemonMode = 'r';
|
||||
#ifdef WIN32
|
||||
else if (!strcmp(mode, "install"))
|
||||
serviceDaemonMode = 'i';
|
||||
else if (!strcmp(mode, "uninstall"))
|
||||
serviceDaemonMode = 'u';
|
||||
#else
|
||||
else if (!strcmp(mode, "stop"))
|
||||
stopDaemon();
|
||||
serviceDaemonMode = 's';
|
||||
#endif
|
||||
else
|
||||
{
|
||||
sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode);
|
||||
|
|
@ -157,7 +132,6 @@ extern int main(int argc, char **argv)
|
|||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case ':':
|
||||
|
|
@ -173,13 +147,40 @@ extern int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32 // need call after options for windows service
|
||||
#ifndef WIN32 // posix daemon commands need apply before config read
|
||||
switch (serviceDaemonMode)
|
||||
{
|
||||
case 'r':
|
||||
startDaemon();
|
||||
break;
|
||||
case 's':
|
||||
stopDaemon();
|
||||
break
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!sConfig.SetSource(cfg_file))
|
||||
{
|
||||
sLog.outError("Could not find configuration file %s.", cfg_file);
|
||||
Log::WaitBeforeContinueIfNeed();
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WIN32 // windows service command need execute after config read
|
||||
switch (serviceDaemonMode)
|
||||
{
|
||||
case 'i':
|
||||
if (WinServiceInstall())
|
||||
sLog.outString("Installing service");
|
||||
return 1;
|
||||
case 'u':
|
||||
if (WinServiceUninstall())
|
||||
sLog.outString("Uninstalling service");
|
||||
return 1;
|
||||
case 'r':
|
||||
WinServiceRun();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
sLog.Initialize();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11506"
|
||||
#define REVISION_NR "11507"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue