Revision
16558
Author
mrene
Date
2010-02-02 16:53:36 -0600 (Tue, 02 Feb 2010)

Log Message

Delay windows service startup so other command line options are processed

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch.c (16557 => 16558)


--- freeswitch/trunk/src/switch.c	2010-02-02 21:04:41 UTC (rev 16557)
+++ freeswitch/trunk/src/switch.c	2010-02-02 22:53:36 UTC (rev 16558)
@@ -267,6 +267,8 @@
 	int nf = 0;					/* TRUE if we are running in nofork mode */
 	char *runas_user = NULL;
 	char *runas_group = NULL;
+#else
+	int win32_service = 0;
 #endif
 	int nc = 0;					/* TRUE if we are running in noconsole mode */
 	pid_t pid = 0;
@@ -357,19 +359,9 @@
 				} else {
 					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++;
-					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);
-				}
+				known_opt++;
+				win32_service++;
+				continue;
 			}
 			if (local_argv[x] && !strcmp(local_argv[x], "-install")) {
 				char exePath[1024];
@@ -744,6 +736,21 @@
 			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
 
 	switch_core_set_globals();