add --with-rundir configure param and -run freeswitch runtime param to adjust the location of the pid file (FSBUILD-188)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14768 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
01e2a5ee74
commit
107f913598
|
@ -38,6 +38,13 @@ AC_ARG_WITH([modinstdir],
|
|||
AC_SUBST(modinstdir)
|
||||
AC_DEFINE_UNQUOTED([SWITCH_MOD_DIR],"${modinstdir}",[where to install the modules to])
|
||||
|
||||
# Where to put pidfile
|
||||
AC_ARG_WITH([rundir],
|
||||
[AS_HELP_STRING([--with-rundir=DIR], [Put pidfile into this location (default: $prefix/log)])], [rundir="$withval"], [rundir="${prefix}/log"])
|
||||
|
||||
AC_SUBST(rundir)
|
||||
AC_DEFINE_UNQUOTED([SWITCH_RUN_DIR],"${rundir}",[where to put pidfile to])
|
||||
|
||||
if test "$sysconfdir" = "\${prefix}/etc" ; then
|
||||
confdir="$prefix/conf"
|
||||
else
|
||||
|
|
|
@ -358,6 +358,7 @@ struct switch_directories {
|
|||
char *mod_dir;
|
||||
char *conf_dir;
|
||||
char *log_dir;
|
||||
char *run_dir;
|
||||
char *db_dir;
|
||||
char *script_dir;
|
||||
char *temp_dir;
|
||||
|
|
21
src/switch.c
21
src/switch.c
|
@ -91,7 +91,7 @@ static int freeswitch_kill_background()
|
|||
switch_core_set_globals();
|
||||
|
||||
/* get the full path of the pid file. */
|
||||
switch_snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||
switch_snprintf(path, sizeof(path), "%s%s%s", SWITCH_GLOBAL_dirs.run_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||
|
||||
/* open the pid file */
|
||||
if ((f = fopen(path, "r")) == 0) {
|
||||
|
@ -333,6 +333,7 @@ int main(int argc, char *argv[])
|
|||
"\t-c -- output to a console and stay in the foreground\n"
|
||||
"\t-conf [confdir] -- specify an alternate config dir\n"
|
||||
"\t-log [logdir] -- specify an alternate log dir\n"
|
||||
"\t-run [rundir] -- specify an alternate run dir\n"
|
||||
"\t-db [dbdir] -- specify an alternate db dir\n"
|
||||
"\t-mod [moddir] -- specify an alternate mod dir\n"
|
||||
"\t-htdocs [htdocsdir] -- specify an alternate htdocs dir\n"
|
||||
|
@ -559,6 +560,22 @@ int main(int argc, char *argv[])
|
|||
known_opt++;
|
||||
}
|
||||
|
||||
if (local_argv[x] && !strcmp(local_argv[x], "-run")) {
|
||||
x++;
|
||||
if (local_argv[x] && strlen(local_argv[x])) {
|
||||
SWITCH_GLOBAL_dirs.run_dir = (char *) malloc(strlen(local_argv[x]) + 1);
|
||||
if (!SWITCH_GLOBAL_dirs.run_dir) {
|
||||
fprintf(stderr, "Allocation error\n");
|
||||
return 255;
|
||||
}
|
||||
strcpy(SWITCH_GLOBAL_dirs.run_dir, local_argv[x]);
|
||||
} else {
|
||||
fprintf(stderr, "When using -run you must specify a pid directory\n");
|
||||
return 255;
|
||||
}
|
||||
known_opt++;
|
||||
}
|
||||
|
||||
if (local_argv[x] && !strcmp(local_argv[x], "-db")) {
|
||||
x++;
|
||||
if (local_argv[x] && strlen(local_argv[x])) {
|
||||
|
@ -690,7 +707,7 @@ int main(int argc, char *argv[])
|
|||
pid = getpid();
|
||||
|
||||
memset(pid_buffer, 0, sizeof(pid_buffer));
|
||||
switch_snprintf(pid_path, sizeof(pid_path), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||
switch_snprintf(pid_path, sizeof(pid_path), "%s%s%s", SWITCH_GLOBAL_dirs.run_dir, SWITCH_PATH_SEPARATOR, pfile);
|
||||
switch_snprintf(pid_buffer, sizeof(pid_buffer), "%d", pid);
|
||||
pid_len = strlen(pid_buffer);
|
||||
|
||||
|
|
|
@ -450,6 +450,14 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (!SWITCH_GLOBAL_dirs.run_dir && (SWITCH_GLOBAL_dirs.run_dir = (char *) malloc(BUFSIZE))) {
|
||||
#ifdef SWITCH_RUN_DIR
|
||||
switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, "%s", SWITCH_RUN_DIR);
|
||||
#else
|
||||
switch_snprintf(SWITCH_GLOBAL_dirs.run_dir, BUFSIZE, "%s%slog", base_dir, SWITCH_PATH_SEPARATOR);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!SWITCH_GLOBAL_dirs.storage_dir && (SWITCH_GLOBAL_dirs.storage_dir = (char *) malloc(BUFSIZE))) {
|
||||
#ifdef SWITCH_STORAGE_DIR
|
||||
switch_snprintf(SWITCH_GLOBAL_dirs.storage_dir, BUFSIZE, "%s", SWITCH_STORAGE_DIR);
|
||||
|
@ -507,6 +515,7 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
|
|||
switch_assert(SWITCH_GLOBAL_dirs.mod_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.conf_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.log_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.run_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.db_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.script_dir);
|
||||
switch_assert(SWITCH_GLOBAL_dirs.htdocs_dir);
|
||||
|
@ -1195,6 +1204,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.mod_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.conf_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.log_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.db_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.script_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
switch_dir_make_recursive(SWITCH_GLOBAL_dirs.htdocs_dir, SWITCH_DEFAULT_DIR_PERMS, runtime.memory_pool);
|
||||
|
|
Loading…
Reference in New Issue