diff options
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/options.c b/src/options.c index f74445b..c531070 100644 --- a/src/options.c +++ b/src/options.c @@ -172,6 +172,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_PARAM("-C","--chroot", opt->chroot_dir_) PARSE_STRING_PARAM("-P","--write-pid", opt->pid_file_) PARSE_STRING_LIST("-L","--log", opt->log_targets_) + PARSE_BOOL_PARAM("-U", "--debug", opt->debug_) PARSE_STRING_PARAM("-s","--command-sock", opt->command_sock_) PARSE_STRING_PARAM("-x","--script", opt->script_) PARSE_INT_PARAM("-m","--max-children", opt->max_children_) @@ -180,6 +181,14 @@ int options_parse(options_t* opt, int argc, char* argv[]) return i; } + if(opt->debug_) { + string_list_add(&opt->log_targets_, "stdout:5"); + opt->daemonize_ = 0; + } + + if(!opt->dirs_.first_ && !opt->command_sock_) + opt->command_sock_ = strdup("/var/run/dropnroll/cmd.sock"); + return 0; } @@ -212,8 +221,9 @@ void options_default(options_t* opt) opt->chroot_dir_ = NULL; opt->pid_file_ = NULL; string_list_init(&opt->log_targets_); + opt->debug_ = 0; - opt->command_sock_ = strdup("/var/run/dropnroll/cmd.sock"); + opt->command_sock_ = NULL; opt->script_ = strdup("newfile.sh"); opt->max_children_ = 8; string_list_init(&opt->dirs_); @@ -255,6 +265,7 @@ void options_print_usage() printf(" [-P|--write-pid] <path> write pid to this file\n"); printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n"); printf(" add a log target, can be invoked several times\n"); + printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n"); printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/dropnroll/cmd.sock\n"); printf(" [-x|--script] <script> the command socket e.g. newfile.sh\n"); printf(" [-m|--max-children] <#of children> limit of children to be started e.g. 8\n"); @@ -274,6 +285,7 @@ void options_print(options_t* opt) printf("pid_file: '%s'\n", opt->pid_file_); printf("log_targets: \n"); string_list_print(&opt->log_targets_, " '", "'\n"); + printf("debug: %s\n", !opt->debug_ ? "false" : "true"); printf("command_sock: '%s'\n", opt->command_sock_); printf("script: '%s'\n", opt->script_); |