Skip to content

Commit

Permalink
bin: add --dry-run check configuration option (fluent#2179)
Browse files Browse the repository at this point in the history
Signed-off-by: Satoshi Tanaka <satoshi.tanaka@crowdworks.co.jp>
  • Loading branch information
kangaechu authored Dec 13, 2020
1 parent f80fb4c commit 3ec1528
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/fluent-bit/flb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ struct flb_config {
void *sched;

struct flb_task_map tasks_map[2048];

int dry_run;
};

#define FLB_CONFIG_LOG_LEVEL(c) (c->log->level)
Expand Down
12 changes: 11 additions & 1 deletion src/fluent-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static void flb_help(int rc, struct flb_config *config)
printf("%sAvailable Options%s\n", ANSI_BOLD, ANSI_RESET);
printf(" -b --storage_path=PATH\tspecify a storage buffering path\n");
printf(" -c --config=FILE\tspecify an optional configuration file\n");
printf(" -D, --dry-run\tdry run\n");
#ifdef FLB_HAVE_FORK
printf(" -d, --daemon\t\trun Fluent Bit in background mode\n");
#endif
Expand Down Expand Up @@ -773,6 +774,7 @@ int flb_main(int argc, char **argv)
#ifdef FLB_HAVE_FORK
{ "daemon", no_argument , NULL, 'd' },
#endif
{ "dry-run", no_argument , NULL, 'D' },
{ "flush", required_argument, NULL, 'f' },
{ "http", no_argument , NULL, 'H' },
{ "log_file", required_argument, NULL, 'l' },
Expand Down Expand Up @@ -821,7 +823,7 @@ int flb_main(int argc, char **argv)

/* Parse the command line options */
while ((opt = getopt_long(argc, argv,
"b:c:df:i:m:o:R:F:p:e:"
"b:c:dDf:i:m:o:R:F:p:e:"
"t:T:l:vqVhL:HP:s:S",
long_opts, NULL)) != -1) {

Expand All @@ -837,6 +839,9 @@ int flb_main(int argc, char **argv)
config->daemon = FLB_TRUE;
break;
#endif
case 'D':
config->dry_run = FLB_TRUE;
break;
case 'e':
ret = flb_plugin_load_router(optarg, config);
if (ret == -1) {
Expand Down Expand Up @@ -1025,6 +1030,11 @@ int flb_main(int argc, char **argv)
win32_started();
#endif

if (config->dry_run == FLB_TRUE) {
fprintf(stderr, "configuration test is successful\n");
exit(EXIT_SUCCESS);
}

ret = flb_start(ctx);
if (ret != 0) {
flb_destroy(ctx);
Expand Down

0 comments on commit 3ec1528

Please sign in to comment.