add a command-line flag and option to force forking, even with -v or -d
rename a flag to have the proper name git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
d7aead737d
commit
eb38f13a2e
13
asterisk.c
13
asterisk.c
|
@ -2179,6 +2179,9 @@ static void ast_readconfig(void)
|
||||||
/* Disable forking (-f at startup) */
|
/* Disable forking (-f at startup) */
|
||||||
} else if (!strcasecmp(v->name, "nofork")) {
|
} else if (!strcasecmp(v->name, "nofork")) {
|
||||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
|
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
|
||||||
|
/* Always fork, even if verbose or debug are enabled (-F at startup) */
|
||||||
|
} else if (!strcasecmp(v->name, "alwaysfork")) {
|
||||||
|
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
|
||||||
/* Run quietly (-q at startup ) */
|
/* Run quietly (-q at startup ) */
|
||||||
} else if (!strcasecmp(v->name, "quiet")) {
|
} else if (!strcasecmp(v->name, "quiet")) {
|
||||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
|
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
|
||||||
|
@ -2289,6 +2292,9 @@ int main(int argc, char *argv[])
|
||||||
/* Check for options */
|
/* Check for options */
|
||||||
while ((c = getopt(argc, argv, "tThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
|
while ((c = getopt(argc, argv, "tThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'F':
|
||||||
|
ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
option_debug++;
|
option_debug++;
|
||||||
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
|
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
|
||||||
|
@ -2366,6 +2372,11 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ast_opt_always_fork && (ast_opt_remote || ast_opt_console)) {
|
||||||
|
ast_log(LOG_WARNING, "'alwaysfork' is not compatible with console or remote console mode; ignored\n");
|
||||||
|
ast_clear_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
|
||||||
|
}
|
||||||
|
|
||||||
/* For remote connections, change the name of the remote connection.
|
/* For remote connections, change the name of the remote connection.
|
||||||
* We do this for the benefit of init scripts (which need to know if/when
|
* We do this for the benefit of init scripts (which need to know if/when
|
||||||
* the main asterisk process has died yet). */
|
* the main asterisk process has died yet). */
|
||||||
|
@ -2506,7 +2517,7 @@ int main(int argc, char *argv[])
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
||||||
|
|
||||||
if (!option_verbose && !option_debug && !ast_opt_no_fork && !ast_opt_console) {
|
if (ast_opt_always_fork || !ast_opt_no_fork) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
/* Blindly re-write pid file since we are forking */
|
/* Blindly re-write pid file since we are forking */
|
||||||
unlink(ast_config_AST_PID);
|
unlink(ast_config_AST_PID);
|
||||||
|
|
2
cdr.c
2
cdr.c
|
@ -1087,7 +1087,7 @@ static int do_reload(void)
|
||||||
batchtime = cfg_time;
|
batchtime = cfg_time;
|
||||||
}
|
}
|
||||||
if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten")))
|
if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten")))
|
||||||
ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_END_CDR_BEFORE_H_EXTEN);
|
ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled && !batchmode) {
|
if (enabled && !batchmode) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ astlogdir => /var/log/asterisk
|
||||||
verbose = 0 ; Verbosity level for logging (-v)
|
verbose = 0 ; Verbosity level for logging (-v)
|
||||||
debug = 3 ; Debug: "No" or value (1-4)
|
debug = 3 ; Debug: "No" or value (1-4)
|
||||||
nofork=yes | no ; Background execution disabled (-f)
|
nofork=yes | no ; Background execution disabled (-f)
|
||||||
|
alwaysfork=yes | no ; Always background, even with -v or -d (-F)
|
||||||
console= yes | no ; Console mode (-c)
|
console= yes | no ; Console mode (-c)
|
||||||
highpriority = yes | no ; Execute with high priority (-p)
|
highpriority = yes | no ; Execute with high priority (-p)
|
||||||
initcrypto = yes | no ; Initialize crypto at startup (-i)
|
initcrypto = yes | no ; Initialize crypto at startup (-i)
|
||||||
|
|
|
@ -71,9 +71,11 @@ enum ast_option_flags {
|
||||||
/*! Suppress some warnings */
|
/*! Suppress some warnings */
|
||||||
AST_OPT_FLAG_DONT_WARN = (1 << 18),
|
AST_OPT_FLAG_DONT_WARN = (1 << 18),
|
||||||
/*! End CDRs before the 'h' extension */
|
/*! End CDRs before the 'h' extension */
|
||||||
AST_OPT_END_CDR_BEFORE_H_EXTEN = (1 << 19),
|
AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19),
|
||||||
/*! Use Zaptel Timing for generators if available */
|
/*! Use Zaptel Timing for generators if available */
|
||||||
AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20)
|
AST_OPT_FLAG_INTERNAL_TIMING = (1 << 20),
|
||||||
|
/*! Always fork, even if verbose or debug settings are non-zero */
|
||||||
|
AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! These are the options that set by default when Asterisk starts */
|
/*! These are the options that set by default when Asterisk starts */
|
||||||
|
@ -98,8 +100,9 @@ enum ast_option_flags {
|
||||||
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
|
#define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
|
||||||
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
|
#define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
|
||||||
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
|
#define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
|
||||||
#define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_END_CDR_BEFORE_H_EXTEN)
|
#define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)
|
||||||
#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING)
|
#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING)
|
||||||
|
#define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
|
||||||
|
|
||||||
extern struct ast_flags ast_options;
|
extern struct ast_flags ast_options;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue