[Aggregator] Add option -G (dump configuration)
Add the option -G (like "Generate configuration file") that dumps the current configuration on the standard output, so the user can call owlps-aggregatord [custom options] -G >owlps-aggregator.conf to generate the configuration file owlps-aggregator.conf.
This commit is contained in:
parent
5ddca24738
commit
94e5c5cbab
|
@ -25,7 +25,7 @@
|
|||
|
||||
|
||||
/* Arguments & program configuration */
|
||||
#define OPTIONS "Ac:C:Df:hH:i:k:K:l:o:O:p:qt:vV" // getopt string
|
||||
#define OPTIONS "Ac:C:Df:GhH:i:k:K:l:o:O:p:qt:vV" // getopt string
|
||||
#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-aggregator.conf"
|
||||
#define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds
|
||||
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
||||
|
|
|
@ -39,6 +39,13 @@
|
|||
char *program_name = NULL ;
|
||||
cfg_t *cfg = NULL ; // Configuration structure
|
||||
|
||||
/* Will we dump the configuration?
|
||||
* Note that we declare this option as a global variable because
|
||||
* it must not appear in Confuse's options (to avoid dumping the
|
||||
* dump_configuration option itself).
|
||||
*/
|
||||
bool dump_configuration = false ;
|
||||
|
||||
request_list *requests = NULL ; // Computed data list
|
||||
sem_t lock_requests ; // Semaphore to get access to the requests
|
||||
|
||||
|
@ -208,6 +215,14 @@ int initialise_configuration(int argc, char **argv)
|
|||
if (! owl_run)
|
||||
return ret ;
|
||||
|
||||
/* Configuration dumping */
|
||||
if (dump_configuration)
|
||||
{
|
||||
cfg_print(cfg, stdout) ;
|
||||
owl_run = false ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/* Configuration printing */
|
||||
if (VERBOSE_INFO)
|
||||
{
|
||||
|
@ -354,6 +369,11 @@ int parse_command_line(int argc, char **argv)
|
|||
break ;
|
||||
case 'f' : // Config file
|
||||
break ; // (already parsed)
|
||||
case 'G' :
|
||||
dump_configuration = true ;
|
||||
/* We must not turn owl_run false here, to avoid the default
|
||||
* check on its value in initialise_configuration(). */
|
||||
break ;
|
||||
case 'H' :
|
||||
cfg_setint(cfg, "autocalibration_hello_port",
|
||||
strtol(optarg, NULL, 0)) ;
|
||||
|
@ -1414,6 +1434,7 @@ void print_usage()
|
|||
printf("Usage:\n"
|
||||
"\t%s"
|
||||
" [-f config_file]"
|
||||
" [-G]"
|
||||
" [-D]"
|
||||
" [-v[v[v[v]]] | -q]"
|
||||
" -o out_file"
|
||||
|
@ -1436,10 +1457,13 @@ void print_usage()
|
|||
"\t%s -V\n"
|
||||
|
||||
"Main options:\n"
|
||||
"\t-h\t\tPrint this help.\n"
|
||||
"\t-V\t\tShow version information.\n"
|
||||
"\t-h\t\tPrint this help message and exit.\n"
|
||||
"\t-V\t\tShow version information and exit.\n"
|
||||
"\t-f config_file\tUse 'config_file' instead of the default"
|
||||
" configuration\n\t\t\tfile (%s).\n"
|
||||
"\t-G\t\tDump the configuration on the standard output and exit"
|
||||
"\n\t\t\t(useful to generate a configuration file from the"
|
||||
"\n\t\t\tcurrent set of options).\n"
|
||||
"\t-D\t\tDaemon mode.\n"
|
||||
"\t-v\t\tBe verbose. You can use this option up to 4 times to"
|
||||
"\n\t\t\tincrease the level of verbosity (1 = warnings,\n\t\t\t"
|
||||
|
|
Loading…
Reference in New Issue