Skip to content
Snippets Groups Projects
Commit 3fea146b authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

config: add pidfile directive, defaults to $(rundir)/knot.pid

issue #67
parent bbb24702
No related branches found
No related tags found
No related merge requests found
......@@ -531,11 +531,7 @@ system:
| 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 RUNDIR TEXT ';' { new_config->rundir = $3.t; }
| system PIDFILE TEXT ';' {
fprintf(stderr, "warning: Config option 'system.pidfile' is deprecated "
"and has no effect. Use 'rundir' instead.\n");
free($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");
......
......@@ -680,6 +680,10 @@ void conf_truncate(conf_t *conf, int unload_hooks)
free(conf->rundir);
conf->rundir = 0;
}
if (conf->pidfile) {
free(conf->pidfile);
conf->pidfile = 0;
}
if (conf->nsid) {
free(conf->nsid);
conf->nsid = 0;
......
......@@ -194,7 +194,8 @@ typedef struct conf_t {
char *hostname; /*!< Host name to return on CH TXT hostname.{bind,server} */
char *version; /*!< Version for CH TXT version.{bind|server} */
char *storage; /*!< Persistent storage path for databases and such. */
char *rundir; /*!< Run-time directory path. */
char *rundir; /*!< Run-time directory path. */
char *pidfile; /*!< PID file location. */
char *nsid; /*!< Server's NSID. */
size_t nsid_len;/*!< Server's NSID length. */
int workers; /*!< Number of workers per interface. */
......
......@@ -39,8 +39,12 @@ char* pid_filename()
/* Read configuration. */
char* ret = NULL;
if (conf() && conf()->rundir != NULL) {
ret = strcdup(conf()->rundir, "/knot.pid");
if (conf()) {
if (conf()->pidfile != NULL)
ret = strdup(conf()->pidfile);
else if (conf()->rundir != NULL)
ret = strcdup(conf()->rundir, "/knot.pid");
}
rcu_read_unlock();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment