From: Derrick Stolee <dstolee@xxxxxxxxxxxxx> The previous change used the job.loopInterval config option to adjust the default sleep between iterations of the job loop in 'git job-runner'. Now, add a command-line option so a user can override the configured value with an explicit value. The value specified by this command-line option cannot be changed without restarting the job-runner process. RFC QUESTION: Are things like this useful, or should we only use config options for this customization? Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> --- Documentation/git-job-runner.txt | 6 ++++++ builtin/job-runner.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/git-job-runner.txt b/Documentation/git-job-runner.txt index 010b2d05f9b..0719113a008 100644 --- a/Documentation/git-job-runner.txt +++ b/Documentation/git-job-runner.txt @@ -33,6 +33,12 @@ OPTIONS attempts running jobs on repositories located at the provided `<dir>` values. This option can be specified multiple times. +--interval=<span>:: + The job runner pauses between each attempt to run jobs. Use the + specified `<span>` as a number of seconds between each attempt. + If this is not specified, then the default will be found from + `jobs.loopInterval` or the default value of 30 minutes. + CONFIGURATION ------------- diff --git a/builtin/job-runner.c b/builtin/job-runner.c index 7e37b122d99..d1fca2c97b8 100644 --- a/builtin/job-runner.c +++ b/builtin/job-runner.c @@ -258,11 +258,16 @@ static int run_job_loop_step(struct string_list *list) return result; } +static unsigned int arg_interval = 0; + static unsigned int get_loop_interval(void) { /* Default: 30 minutes */ timestamp_t interval = 30 * 60; + if (arg_interval) + return arg_interval; + try_get_timestamp(NULL, ".", "loopinterval", &interval); return interval; @@ -287,6 +292,8 @@ int cmd_job_runner(int argc, const char **argv, const char *prefix) N_("<path>"), N_("run jobs on the repository at <path>"), PARSE_OPT_NONEG, arg_repos_append), + OPT_INTEGER(0, "interval", &arg_interval, + N_("seconds to pause between running any jobs")), OPT_END(), }; -- gitgitgadget