Commit 829036bb authored by Marek Vavrusa's avatar Marek Vavrusa

Added configure options --with-rundir|storage and rundir config opt.

Removed 'pidfile' config option in favour of 'rundir' for later
storage of UNIX sockets and other stuff.
Default of 'rundir' is $(localstatedir)/run/knot
Default of 'storage' is $(sharedstatedir)/knot

refs #36
parent 9be2770c
......@@ -160,6 +160,19 @@ AX_CHECK_COMPILE_FLAG("-fpredictive-commoning", [CFLAGS="$CFLAGS -fpredictive-co
# FIXME: we break strict aliasing on many occurenes, disable it until resolved or kept
AX_CHECK_COMPILE_FLAG("-fno-strict-aliasing", [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
# Default directories
run_dir="${localstatedir}/run/knot"
AC_ARG_WITH([rundir],
AC_HELP_STRING([--with-rundir=path], [Path to run-time variable data (pid, sockets...). [default=`eval echo ${localstatedir}`/run/knot]]),
[run_dir=$withval])
AC_SUBST(run_dir)
storage_dir="${sharedstatedir}/knot"
AC_ARG_WITH([storage],
AC_HELP_STRING([--with-storage=path], [Default storage directory (slave zones, persistent data). [default=$(sharedstatedir)/knot]]),
[storage_dir=$withval])
AC_SUBST(storage_dir)
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
......
......@@ -171,7 +171,7 @@ Statement Definition and Usage
* version::
* nsid::
* storage::
* pidfile::
* rundir::
* workers::
* user::
* max-conn-idle::
......
......@@ -39,7 +39,7 @@ else.
[ @code{hostname} @code{"}@kbd{string}@code{";} ]
[ @code{nsid} ( @code{"}@kbd{string}@code{"} | @kbd{hex_string} )@code{;} ]
[ @code{storage} @code{"}@kbd{string}@code{";} ]
[ @code{pidfile} @code{"}@kbd{string}@code{";} ]
[ @code{rundir} @code{"}@kbd{string}@code{";} ]
[ @code{workers} @kbd{integer}@code{;} ]
[ @code{user} @kbd{string}[@code{.}@kbd{string}]@code{;} ]
[ @code{max-conn-idle} ( @kbd{integer} | @kbd{integer}(@code{s} | @code{m} | @code{h} | @code{d})@code{;} ) ]
......@@ -61,7 +61,7 @@ else.
* hostname::
* nsid::
* storage::
* pidfile::
* rundir::
* workers::
* user::
* max-conn-idle::
......@@ -139,7 +139,9 @@ system @{
@subsubsection storage
@vindex storage
The working directory of Knot DNS, it is used to store compiled zone files and it is also a default location of the PID file.
The working directory of Knot DNS, it is used to store compiled zone files and
other persistent data.
Default: @file{$@{sharedstatedir@}/knot}, configured with @code{--with-storage=path}
@example
system @{
......@@ -147,17 +149,16 @@ system @{
@}
@end example
@node pidfile
@subsubsection pidfile
@vindex pidfile
@node rundir
@subsubsection rundir
@vindex rundir
Specifies a custom PID file location.
Default value: @file{knot.pid} in @code{storage} directory.
Path for storing run-time data, for example PID file and unix sockets.
Default: @file{$@{localstatedir@}/run/knot}, configured with @code{--with-rundir=path}
@example
system @{
pidfile "/var/run/knot.pid";
rundir "/var/run/knot";
@}
@end example
......@@ -265,7 +266,7 @@ system @{
version "@value{VERSION}";
nsid "amaterasu";
storage "/var/lib/knot";
pidfile "/var/run/knot.pid";
rundir "/var/run/knot";
workers 16;
user knot.knot;
@}
......
......@@ -65,17 +65,12 @@ Parameters:
@end example
Also, the server needs to create several files in order to run properly.
All files are placed in the directory described by @code{storage} (@pxref{storage}).
PID file can be placed elsewhere using the @code{pidfile} statement (@pxref{pidfile}).
Slave zones with relative path specified will be placed in the @code{storage} as well.
Zones and related data are stored in the directory described by @code{storage} (@pxref{storage}).
@itemize @bullet
@item
@emph{Journal files} - each zone has a journal file to store differences for IXFR and
dynamic updates. Journal for zone @code{example.com} will be
placed in @file{STORAGE/example.com.diff.db}.
@item
@emph{PID file} - unless specified differently by the @code{pidfile}, it will be placed
in the @file{STORAGE/knot.pid}.
@end itemize
@node Running a slave server
......
......@@ -30,11 +30,12 @@ system {
# Working directory of the server
# Used to store compiled zones and PID file
storage "/tmp/knot-sample";
# default: ${sharedstatedir}/knot, configured with --with-storage
storage "/var/lib/knot";
# Custom pidfile path
# default: pidfile is created in 'storage'.
pidfile "/tmp/knot.pid";
# Directory for storing run-time data
# default: ${localstatedir}/run/knot, configured with --with-rundir
rundir "/var/run/knot";
# Number of workers per interface
# This option is used to force number of threads used per interface
......
......@@ -7,7 +7,6 @@
system {
identity "@package@ @version@";
storage "@localstatedir@/@package@";
}
interfaces {
......
......@@ -6,7 +6,9 @@ noinst_PROGRAMS = zscanner-tool
noinst_LTLIBRARIES = libknot.la libknotd.la libknots.la libzscanner.la
# $(YACC) will generate header file
AM_CPPFLAGS = -I$(top_srcdir)/src/libknot -DSYSCONFDIR='"$(sysconfdir)"' -DSBINDIR='"$(sbindir)"'
AM_CPPFLAGS = -I$(top_srcdir)/src/libknot -DSYSCONFDIR='"$(sysconfdir)"' \
-DSBINDIR='"$(sbindir)"' -DSTORAGE_DIR='"${storage_dir}"' \
-DRUN_DIR='"${run_dir}"'
AM_YFLAGS = -d
libknotd_la_YFLAGS = -pcf_ -d
libknotd_la_LFLAGS = # TODO: reentrant parser, prefix
......@@ -308,3 +310,8 @@ kdig_LDADD = libknotd.la libknot.la libknots.la @LIBOBJS@
khost_LDADD = libknotd.la libknot.la libknots.la @LIBOBJS@
knsupdate_LDADD = libknotd.la libknot.la libknots.la libzscanner.la @LIBOBJS@
zscanner_tool_LDADD = libknots.la libknot.la libknotd.la libzscanner.la @LIBOBJS@
# Create storage and run-time directories
install-data-hook:
$(INSTALL) -d @run_dir@
$(INSTALL) -d @storage_dir@
......@@ -115,6 +115,7 @@ 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; }
rundir { lval.t = yytext; return RUNDIR; }
ixfr-from-differences { lval.t = yytext; return BUILD_DIFFS; }
max-conn-idle { lval.t = yytext; return MAX_CONN_IDLE; }
max-conn-handshake { lval.t = yytext; return MAX_CONN_HS; }
......
......@@ -404,6 +404,7 @@ static int conf_mask(void* scanner, int nval, int prefixlen) {
%token <tok> TSIG_ALGO_NAME
%token <tok> WORKERS
%token <tok> USER
%token <tok> RUNDIR
%token <tok> PIDFILE
%token <tok> REMOTES
......@@ -529,7 +530,12 @@ 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 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 KEY TSIG_ALGO_NAME TEXT ';' {
fprintf(stderr, "warning: Config option 'system.key' is deprecated "
"and has no effect.\n");
......
......@@ -146,7 +146,7 @@ static int conf_process(conf_t *conf)
{
// Check
if (conf->storage == NULL) {
conf->storage = strdup("/var/lib/"PROJECT_EXENAME);
conf->storage = strdup(STORAGE_DIR);
if (conf->storage == NULL) {
return KNOT_ENOMEM;
}
......@@ -170,9 +170,9 @@ static int conf_process(conf_t *conf)
}
// Create PID file
if (conf->pidfile == NULL) {
conf->pidfile = strcdup(conf->storage, "/" PID_FILE);
if (conf->pidfile == NULL) {
if (conf->rundir == NULL) {
conf->rundir = strdup(RUN_DIR);
if (conf->rundir == NULL) {
return KNOT_ENOMEM;
}
}
......@@ -384,7 +384,7 @@ void __attribute__ ((constructor)) conf_init()
++s_config->ifaces_count;
/* Create default storage. */
s_config->storage = strdup("/var/lib/"PROJECT_EXENAME);
s_config->storage = strdup(STORAGE_DIR);
/* Create default logs. */
......@@ -682,9 +682,9 @@ void conf_truncate(conf_t *conf, int unload_hooks)
free(conf->storage);
conf->storage = 0;
}
if (conf->pidfile) {
free(conf->pidfile);
conf->pidfile = 0;
if (conf->rundir) {
free(conf->rundir);
conf->rundir = 0;
}
if (conf->nsid) {
free(conf->nsid);
......
......@@ -194,7 +194,7 @@ 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 *pidfile; /*!< PID file path. */
char *rundir; /*!< Run-time directory path. */
char *nsid; /*!< Server's NSID. */
size_t nsid_len;/*!< Server's NSID length. */
int workers; /*!< Number of workers per interface. */
......
......@@ -37,9 +37,9 @@ char* pid_filename()
rcu_read_lock();
/* Read configuration. */
char* ret = 0;
if (conf() && conf()->pidfile != NULL) {
ret = strdup(conf()->pidfile);
char* ret = NULL;
if (conf() && conf()->rundir != NULL) {
ret = strcdup(conf()->rundir, "/knot.pid");
}
rcu_read_unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment