(main,service_main) [_WIN32]: Change startup errors to stderr from
logerror() as log file is not open yet.
This commit is contained in:
parent
f03de3f9a5
commit
98f3d6efca
2 changed files with 13 additions and 13 deletions
|
@ -70,7 +70,7 @@ install_service(char *program_name, char *service_name, int datadir_set, char *c
|
||||||
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
schSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (schSCManager == NULL) {
|
if (schSCManager == NULL) {
|
||||||
logerror("install_service failed to open Service Control Manager");
|
fprintf(stderr, "install_service failed to open Service Control Manager\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ install_service(char *program_name, char *service_name, int datadir_set, char *c
|
||||||
NULL); /* no password */
|
NULL); /* no password */
|
||||||
|
|
||||||
if (schService == NULL) {
|
if (schService == NULL) {
|
||||||
logerror("install_service failed to create service %s", service_name);
|
fprintf(stderr, "install_service failed to create service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sdBuf.lpDescription = "Server for Empire game";
|
sdBuf.lpDescription = "Server for Empire game";
|
||||||
|
@ -100,7 +100,7 @@ install_service(char *program_name, char *service_name, int datadir_set, char *c
|
||||||
schService, /* handle to service */
|
schService, /* handle to service */
|
||||||
SERVICE_CONFIG_DESCRIPTION, /* change: description */
|
SERVICE_CONFIG_DESCRIPTION, /* change: description */
|
||||||
&sdBuf)) { /* value: new description */
|
&sdBuf)) { /* value: new description */
|
||||||
logerror("install_service failed to set the description");
|
fprintf(stderr, "install_service failed to set the description\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Service %s installed.\n", service_name);
|
printf("Service %s installed.\n", service_name);
|
||||||
|
@ -122,24 +122,24 @@ remove_service(char *service_name)
|
||||||
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (schSCManager == NULL) {
|
if (schSCManager == NULL) {
|
||||||
logerror("remove_service failed to open Service Control Manager");
|
fprintf(stderr, "remove_service failed to open Service Control Manager\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
|
hService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
|
||||||
|
|
||||||
if (hService == NULL) {
|
if (hService == NULL) {
|
||||||
logerror("remove_service failed to open service %s", service_name);
|
fprintf(stderr, "remove_service failed to open service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeleteService(hService) == 0) {
|
if (DeleteService(hService) == 0) {
|
||||||
logerror("remove_service failed to remove service %s", service_name);
|
fprintf(stderr, "remove_service failed to remove service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CloseServiceHandle(hService) == 0) {
|
if (CloseServiceHandle(hService) == 0) {
|
||||||
logerror("remove_service failed to close service %s", service_name);
|
fprintf(stderr, "remove_service failed to close service %s\n", service_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} else {
|
} else {
|
||||||
printf("Service %s removed.\n", service_name);
|
printf("Service %s removed.\n", service_name);
|
||||||
|
|
|
@ -169,18 +169,18 @@ main(int argc, char **argv)
|
||||||
#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) {
|
||||||
logerror("Can't use -d, -D or -e with either "
|
fprintf(stderr, "Can't use -d, -D or -e with either "
|
||||||
"-r or -R options when starting the server");
|
"-r or -R options when starting the server\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (debug && install_service_set) {
|
if (debug && install_service_set) {
|
||||||
logerror("Can't use -d with either "
|
fprintf(stderr, "Can't use -d with either "
|
||||||
"-i or -I options when starting the server");
|
"-i or -I options when starting the server\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (install_service_set && remove_service_set) {
|
if (install_service_set && remove_service_set) {
|
||||||
logerror("Can't use both -r or -R and -i or -I options when starting "
|
fprintf(stderr, "Can't use both -r or -R and -i or -I options when starting "
|
||||||
"the server");
|
"the server\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue