forked from Mirrors/freeswitch
Delay windows service startup so other command line options are processed
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16558 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
86e022f516
commit
192288bbc8
31
src/switch.c
31
src/switch.c
|
@ -267,6 +267,8 @@ int main(int argc, char *argv[])
|
||||||
int nf = 0; /* TRUE if we are running in nofork mode */
|
int nf = 0; /* TRUE if we are running in nofork mode */
|
||||||
char *runas_user = NULL;
|
char *runas_user = NULL;
|
||||||
char *runas_group = NULL;
|
char *runas_group = NULL;
|
||||||
|
#else
|
||||||
|
int win32_service = 0;
|
||||||
#endif
|
#endif
|
||||||
int nc = 0; /* TRUE if we are running in noconsole mode */
|
int nc = 0; /* TRUE if we are running in noconsole mode */
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
|
@ -357,19 +359,9 @@ int main(int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
switch_copy_string(service_name, SERVICENAME_DEFAULT, SERVICENAME_MAXLEN);
|
switch_copy_string(service_name, SERVICENAME_DEFAULT, SERVICENAME_MAXLEN);
|
||||||
}
|
}
|
||||||
{ /* Attempt to start service */
|
|
||||||
SERVICE_TABLE_ENTRY dispatchTable[] = {
|
|
||||||
{service_name, &service_main},
|
|
||||||
{NULL, NULL}
|
|
||||||
};
|
|
||||||
known_opt++;
|
known_opt++;
|
||||||
if (StartServiceCtrlDispatcher(dispatchTable) == 0) {
|
win32_service++;
|
||||||
/* Not loaded as a service */
|
continue;
|
||||||
fprintf(stderr, "Error Freeswitch loaded as a console app with -service option\n");
|
|
||||||
fprintf(stderr, "To install the service load freeswitch with -install\n");
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (local_argv[x] && !strcmp(local_argv[x], "-install")) {
|
if (local_argv[x] && !strcmp(local_argv[x], "-install")) {
|
||||||
char exePath[1024];
|
char exePath[1024];
|
||||||
|
@ -744,6 +736,21 @@ int main(int argc, char *argv[])
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (win32_service) {
|
||||||
|
{ /* Attempt to start service */
|
||||||
|
SERVICE_TABLE_ENTRY dispatchTable[] = {
|
||||||
|
{service_name, &service_main},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
if (StartServiceCtrlDispatcher(dispatchTable) == 0) {
|
||||||
|
/* Not loaded as a service */
|
||||||
|
fprintf(stderr, "Error Freeswitch loaded as a console app with -service option\n");
|
||||||
|
fprintf(stderr, "To install the service load freeswitch with -install\n");
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch_core_set_globals();
|
switch_core_set_globals();
|
||||||
|
|
Loading…
Reference in New Issue