From 3d177acc0bcdf903277c1f020f5a6e92fb339407 Mon Sep 17 00:00:00 2001 From: Marek Vavrusa <marek@vavrusa.com> Date: Fri, 10 Feb 2012 20:57:33 +0100 Subject: [PATCH] New system.pidfile config file option. Usage: system { pidfile "/tmp/knot.pid"; } --- samples/knot.full.conf | 4 ++++ src/knot/conf/cf-lex.l | 1 + src/knot/conf/cf-parse.y | 2 ++ src/knot/conf/conf.c | 4 +++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/samples/knot.full.conf b/samples/knot.full.conf index 55084bdc3c..91d5674574 100644 --- a/samples/knot.full.conf +++ b/samples/knot.full.conf @@ -29,6 +29,10 @@ system { # Used to store compiled zones and PID file storage "/tmp/knot-sample"; + # Custom pidfile path + # default: pidfile is created in 'storage'. + pidfile "/tmp/knot.pid"; + # Number of workers per interface # This option is used to force number of threads used per interface # Default: unset (auto-estimates optimal value from the number of online CPUs) diff --git a/src/knot/conf/cf-lex.l b/src/knot/conf/cf-lex.l index c3cc866e72..6683edccfc 100644 --- a/src/knot/conf/cf-lex.l +++ b/src/knot/conf/cf-lex.l @@ -89,6 +89,7 @@ notify-in { lval.t = yytext; return NOTIFY_IN; } notify-out { lval.t = yytext; return NOTIFY_OUT; } workers { lval.t = yytext; return WORKERS; } user { lval.t = yytext; return USER; } +pidfile { lval.t = yytext; return PIDFILE; } interfaces { lval.t = yytext; return INTERFACES; } address { lval.t = yytext; return ADDRESS; } diff --git a/src/knot/conf/cf-parse.y b/src/knot/conf/cf-parse.y index 9e282ec475..9d68d900d3 100644 --- a/src/knot/conf/cf-parse.y +++ b/src/knot/conf/cf-parse.y @@ -177,6 +177,7 @@ static int conf_key_add(void *scanner, knot_key_t **key, char *item) %token <tok> TSIG_ALGO_NAME %token <tok> WORKERS %token <tok> USER +%token <tok> PIDFILE %token <tok> REMOTES @@ -289,6 +290,7 @@ system: | system NSID HEXSTR ';' { new_config->nsid = $3.t; new_config->nsid_len = $3.l; } | system NSID TEXT ';' { new_config->nsid = $3.t; new_config->nsid_len = strlen(new_config->nsid); } | system STORAGE TEXT ';' { new_config->storage = $3.t; } + | system PIDFILE TEXT ';' { new_config->pidfile = $3.t; } | system KEY TSIG_ALGO_NAME TEXT ';' { fprintf(stderr, "warning: Config option 'system.key' is deprecated " "and has no effect.\n"); diff --git a/src/knot/conf/conf.c b/src/knot/conf/conf.c index 44185fd931..a382bbac97 100644 --- a/src/knot/conf/conf.c +++ b/src/knot/conf/conf.c @@ -211,7 +211,9 @@ static int conf_process(conf_t *conf) } // Create PID file - conf->pidfile = strcdup(conf->storage, "/" PID_FILE); + if (conf->pidfile == NULL) { + conf->pidfile = strcdup(conf->storage, "/" PID_FILE); + } // Postprocess zones int ret = KNOTD_EOK; -- GitLab