(start_server, main, service_main): Call emp_config() earlier.
(main): Call loginit() later, after emp_config(). Previously, the program logged to the default datadir until emp_config(). (init_server, start_sever): Split start_server() into initialization and actual startup. Move initialization before disassoc(). (main, init_server): Log server startup only after initialization is complete.
This commit is contained in:
parent
e215af5ac5
commit
830c171dd2
3 changed files with 30 additions and 15 deletions
|
@ -48,7 +48,8 @@
|
||||||
extern void close_files(void);
|
extern void close_files(void);
|
||||||
extern void panic(int sig);
|
extern void panic(int sig);
|
||||||
extern void shutdwn(int sig);
|
extern void shutdwn(int sig);
|
||||||
extern void start_server(int, char *);
|
extern void init_server(int);
|
||||||
|
extern void start_server(int);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
extern void loc_NTTerm(void);
|
extern void loc_NTTerm(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -237,6 +237,7 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
sprintf(tbuf, "%s/econfig", datadir);
|
sprintf(tbuf, "%s/econfig", datadir);
|
||||||
config_file = tbuf;
|
config_file = tbuf;
|
||||||
}
|
}
|
||||||
|
emp_config(config_file);
|
||||||
|
|
||||||
service_status.dwServiceType = SERVICE_WIN32;
|
service_status.dwServiceType = SERVICE_WIN32;
|
||||||
service_status.dwCurrentState = SERVICE_START_PENDING;
|
service_status.dwCurrentState = SERVICE_START_PENDING;
|
||||||
|
@ -255,7 +256,8 @@ service_main(DWORD argc, LPTSTR *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialization code goes here. */
|
/* Initialization code goes here. */
|
||||||
start_server(0, config_file);
|
init_server(0);
|
||||||
|
start_server(0);
|
||||||
|
|
||||||
/* Initialization complete - report running status. */
|
/* Initialization complete - report running status. */
|
||||||
service_status.dwCurrentState = SERVICE_RUNNING;
|
service_status.dwCurrentState = SERVICE_RUNNING;
|
||||||
|
|
|
@ -166,8 +166,6 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loginit("server");
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if ((debug || datadir_set || config_file != NULL) &&
|
if ((debug || datadir_set || config_file != NULL) &&
|
||||||
remove_service_set) {
|
remove_service_set) {
|
||||||
|
@ -190,6 +188,15 @@ main(int argc, char **argv)
|
||||||
printf("Can't use both -r or -R and -i or -I options\n");
|
printf("Can't use both -r or -R and -i or -I options\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
if (config_file == NULL) {
|
||||||
|
sprintf(tbuf, "%s/econfig", datadir);
|
||||||
|
config_file = tbuf;
|
||||||
|
}
|
||||||
|
emp_config(config_file);
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
if (install_service_set)
|
if (install_service_set)
|
||||||
return install_service(argv[0], service_name, datadir_set);
|
return install_service(argv[0], service_name, datadir_set);
|
||||||
if (remove_service_set)
|
if (remove_service_set)
|
||||||
|
@ -201,9 +208,6 @@ main(int argc, char **argv)
|
||||||
config_file = tbuf;
|
config_file = tbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
logerror("------------------------------------------------------");
|
|
||||||
logerror("Empire server (pid %d) started", (int)getpid());
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (debug == 0) {
|
if (debug == 0) {
|
||||||
SERVICE_TABLE_ENTRY DispatchTable[]={{"Empire Server", service_main},{NULL, NULL}};
|
SERVICE_TABLE_ENTRY DispatchTable[]={{"Empire Server", service_main},{NULL, NULL}};
|
||||||
|
@ -217,13 +221,14 @@ main(int argc, char **argv)
|
||||||
} else /* start in the foreground */
|
} else /* start in the foreground */
|
||||||
debug = 1;
|
debug = 1;
|
||||||
}
|
}
|
||||||
#else
|
#endif /* _WIN32 */
|
||||||
if (debug == 0 && flags == 0) {
|
|
||||||
disassoc();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
start_server(flags, config_file);
|
init_server(flags);
|
||||||
|
#ifndef _WIN32
|
||||||
|
if (debug == 0 && flags == 0)
|
||||||
|
disassoc();
|
||||||
|
#endif
|
||||||
|
start_server(flags);
|
||||||
|
|
||||||
#if defined(__linux__) && defined(_EMPTH_POSIX)
|
#if defined(__linux__) && defined(_EMPTH_POSIX)
|
||||||
strcpy(tbuf, argv[0]);
|
strcpy(tbuf, argv[0]);
|
||||||
|
@ -247,7 +252,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
start_server(int flags, char *config_file)
|
init_server(int flags)
|
||||||
{
|
{
|
||||||
#ifdef POSIXSIGNALS
|
#ifdef POSIXSIGNALS
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
@ -256,7 +261,6 @@ start_server(int flags, char *config_file)
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
loc_NTInit();
|
loc_NTInit();
|
||||||
#endif
|
#endif
|
||||||
emp_config(config_file);
|
|
||||||
update_policy_check();
|
update_policy_check();
|
||||||
|
|
||||||
nullify_objects();
|
nullify_objects();
|
||||||
|
@ -316,6 +320,14 @@ start_server(int flags, char *config_file)
|
||||||
mobility_init();
|
mobility_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loginit("server");
|
||||||
|
logerror("------------------------------------------------------");
|
||||||
|
logerror("Empire server (pid %d) started", (int)getpid());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
start_server(int flags)
|
||||||
|
{
|
||||||
empth_create(PP_ACCEPT, player_accept, (50 * 1024), flags,
|
empth_create(PP_ACCEPT, player_accept, (50 * 1024), flags,
|
||||||
"AcceptPlayers", "Accept network connections", 0);
|
"AcceptPlayers", "Accept network connections", 0);
|
||||||
empth_create(PP_KILLIDLE, player_kill_idle, (50 * 1024), flags,
|
empth_create(PP_KILLIDLE, player_kill_idle, (50 * 1024), flags,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue