[Aggregator] Daemon mode (-D)
This commit is contained in:
parent
2ed7ccd4bc
commit
a4857e4b1f
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Arguments & program configuration */
|
/* Arguments & program configuration */
|
||||||
#define OPTIONS "a:Ac:C:f:hi:k:K:l:o:p:qt:vV" // getopt string
|
#define OPTIONS "a:Ac:C:Df:hi:k:K:l:o:p:qt:vV" // getopt string
|
||||||
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
|
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
|
||||||
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
|
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
|
||||||
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
||||||
|
|
|
@ -102,6 +102,14 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg_getbool(cfg, "daemon"))
|
||||||
|
{
|
||||||
|
if (VERBOSE_WARNING)
|
||||||
|
fprintf(stderr, "Detaching to background...\n") ;
|
||||||
|
if (daemon(0, 0))
|
||||||
|
perror("Cannot daemonize") ;
|
||||||
|
}
|
||||||
|
|
||||||
ret = read_loop(sockfd) ;
|
ret = read_loop(sockfd) ;
|
||||||
|
|
||||||
/* Wait for the threads to terminate */
|
/* Wait for the threads to terminate */
|
||||||
|
@ -197,6 +205,9 @@ int parse_config_file(int argc, char **argv)
|
||||||
// Config file options for confuse
|
// Config file options for confuse
|
||||||
cfg_opt_t opts[] =
|
cfg_opt_t opts[] =
|
||||||
{
|
{
|
||||||
|
// Daemon mode
|
||||||
|
CFG_BOOL("daemon", cfg_false, CFGF_NONE),
|
||||||
|
|
||||||
// Verbose level
|
// Verbose level
|
||||||
CFG_INT("verbose", 0, CFGF_NONE),
|
CFG_INT("verbose", 0, CFGF_NONE),
|
||||||
|
|
||||||
|
@ -307,6 +318,9 @@ int parse_command_line(int argc, char **argv)
|
||||||
case 'C' :
|
case 'C' :
|
||||||
cfg_setint(cfg, "ap_check_interval", strtol(optarg, NULL, 0)) ;
|
cfg_setint(cfg, "ap_check_interval", strtol(optarg, NULL, 0)) ;
|
||||||
break ;
|
break ;
|
||||||
|
case 'D' :
|
||||||
|
cfg_setbool(cfg, "daemon", cfg_true) ;
|
||||||
|
break ;
|
||||||
case 'f' : // Config file
|
case 'f' : // Config file
|
||||||
break ; // (already parsed)
|
break ; // (already parsed)
|
||||||
case 'i' :
|
case 'i' :
|
||||||
|
@ -1309,6 +1323,7 @@ void print_usage()
|
||||||
printf("Usage:\n"
|
printf("Usage:\n"
|
||||||
"\t%s"
|
"\t%s"
|
||||||
" [-f config_file]"
|
" [-f config_file]"
|
||||||
|
" [-D]"
|
||||||
" [-v[v[v[v]]] | -q]"
|
" [-v[v[v[v]]] | -q]"
|
||||||
" -o output_file"
|
" -o output_file"
|
||||||
" [-i positionner_ip]"
|
" [-i positionner_ip]"
|
||||||
|
@ -1330,6 +1345,7 @@ void print_usage()
|
||||||
"\t-V\t\tShow version information.\n"
|
"\t-V\t\tShow version information.\n"
|
||||||
"\t-f config_file\tUse 'config_file' instead of the default"
|
"\t-f config_file\tUse 'config_file' instead of the default"
|
||||||
" configuration file (%s).\n"
|
" configuration file (%s).\n"
|
||||||
|
"\t-D\t\tDaemon mode.\n"
|
||||||
"\t-v\t\tBe verbose. You can use this option up to 4 times to"
|
"\t-v\t\tBe verbose. You can use this option up to 4 times to"
|
||||||
" increase the level of verbosity (1 = warnings, 2 = useful"
|
" increase the level of verbosity (1 = warnings, 2 = useful"
|
||||||
" information, 3 = too much information, 4 = displays the"
|
" information, 3 = too much information, 4 = displays the"
|
||||||
|
|
Loading…
Reference in New Issue