fix regression from -run addition and better handling of -stop

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15234 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-10-26 21:46:21 +00:00
parent 8fb754892f
commit 7fbdde93b6
1 changed files with 12 additions and 2 deletions

View File

@ -276,7 +276,7 @@ int main(int argc, char *argv[])
int local_argc = argc; int local_argc = argc;
char *arg_argv[128] = { 0 }; char *arg_argv[128] = { 0 };
char *usageDesc; char *usageDesc;
int alt_dirs = 0; int alt_dirs = 0, log_set = 0, run_set = 0, kill = 0;
int known_opt; int known_opt;
int high_prio = 0; int high_prio = 0;
#ifdef __sun #ifdef __sun
@ -498,7 +498,7 @@ int main(int argc, char *argv[])
} }
if (local_argv[x] && !strcmp(local_argv[x], "-stop")) { if (local_argv[x] && !strcmp(local_argv[x], "-stop")) {
return freeswitch_kill_background(); kill++;
} }
if (local_argv[x] && !strcmp(local_argv[x], "-nc")) { if (local_argv[x] && !strcmp(local_argv[x], "-nc")) {
@ -554,6 +554,7 @@ int main(int argc, char *argv[])
} }
strcpy(SWITCH_GLOBAL_dirs.log_dir, local_argv[x]); strcpy(SWITCH_GLOBAL_dirs.log_dir, local_argv[x]);
alt_dirs++; alt_dirs++;
log_set++;
} else { } else {
fprintf(stderr, "When using -log you must specify a log directory\n"); fprintf(stderr, "When using -log you must specify a log directory\n");
return 255; return 255;
@ -570,6 +571,7 @@ int main(int argc, char *argv[])
return 255; return 255;
} }
strcpy(SWITCH_GLOBAL_dirs.run_dir, local_argv[x]); strcpy(SWITCH_GLOBAL_dirs.run_dir, local_argv[x]);
run_set++;
} else { } else {
fprintf(stderr, "When using -run you must specify a pid directory\n"); fprintf(stderr, "When using -run you must specify a pid directory\n");
return 255; return 255;
@ -631,6 +633,14 @@ int main(int argc, char *argv[])
exit(0); exit(0);
} }
} }
if (log_set && !run_set) {
strcpy(SWITCH_GLOBAL_dirs.run_dir, SWITCH_GLOBAL_dirs.log_dir);
}
if (kill) {
return freeswitch_kill_background();
}
if (apr_initialize() != SWITCH_STATUS_SUCCESS) { if (apr_initialize() != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "FATAL ERROR! Could not initialize APR\n"); fprintf(stderr, "FATAL ERROR! Could not initialize APR\n");