Add configurable persistdir

The persisted configuration file directory is now configurable.
This commit is contained in:
Markus Makela
2016-11-10 11:56:37 +02:00
parent 6847ed1c37
commit aefa5c4c57
2 changed files with 47 additions and 3 deletions

View File

@ -378,6 +378,16 @@ Configure the directory where the executable files reside. All internal processe
execdir=/usr/local/bin/ execdir=/usr/local/bin/
``` ```
#### `persistdir`
Configure the directory where persisted configurations are stored. When a new
server is created via MaxAdmin, it will be stored in this directory. Do not use
or modify the contents of this directory, use _/etc/maxscale.cnf.d/_ instead.
```
persistdir=/var/lib/maxscale/maxscale.cnf.d/
```
#### `language` #### `language`
Set the folder where the errmsg.sys file is located in. MariaDB MaxScale will look for the errmsg.sys file installed with MariaDB MaxScale from this folder. Set the folder where the errmsg.sys file is located in. MariaDB MaxScale will look for the errmsg.sys file installed with MariaDB MaxScale from this folder.

View File

@ -128,6 +128,7 @@ static struct option long_options[] =
{"configdir", required_argument, 0, 'C'}, {"configdir", required_argument, 0, 'C'},
{"datadir", required_argument, 0, 'D'}, {"datadir", required_argument, 0, 'D'},
{"execdir", required_argument, 0, 'E'}, {"execdir", required_argument, 0, 'E'},
{"persistdir", required_argument, 0, 'F'},
{"language", required_argument, 0, 'N'}, {"language", required_argument, 0, 'N'},
{"piddir", required_argument, 0, 'P'}, {"piddir", required_argument, 0, 'P'},
{"basedir", required_argument, 0, 'R'}, {"basedir", required_argument, 0, 'R'},
@ -919,8 +920,9 @@ static void usage(void)
" -B, --libdir=PATH path to module directory\n" " -B, --libdir=PATH path to module directory\n"
" -C, --configdir=PATH path to configuration file directory\n" " -C, --configdir=PATH path to configuration file directory\n"
" -D, --datadir=PATH path to data directory,\n" " -D, --datadir=PATH path to data directory,\n"
" stored embedded mysql tables\n" " stores internal MaxScale data\n"
" -E, --execdir=PATH path to the maxscale and other executable files\n" " -E, --execdir=PATH path to the maxscale and other executable files\n"
" -F, --persistdir=PATH path to persisted configuration directory\n"
" -N, --language=PATH path to errmsg.sys file\n" " -N, --language=PATH path to errmsg.sys file\n"
" -P, --piddir=PATH path to PID file directory\n" " -P, --piddir=PATH path to PID file directory\n"
" -R, --basedir=PATH base path for all other paths\n" " -R, --basedir=PATH base path for all other paths\n"
@ -944,6 +946,7 @@ static void usage(void)
" execdir : %s\n" " execdir : %s\n"
" language : %s\n" " language : %s\n"
" piddir : %s\n" " piddir : %s\n"
" persistdir : %s\n"
"\n" "\n"
"If '--basedir' is provided then all other paths, including the default\n" "If '--basedir' is provided then all other paths, including the default\n"
"configuration file path, are defined relative to that. As an example,\n" "configuration file path, are defined relative to that. As an example,\n"
@ -954,7 +957,8 @@ static void usage(void)
progname, progname,
get_configdir(), default_cnf_fname, get_configdir(), default_cnf_fname,
get_configdir(), get_logdir(), get_cachedir(), get_libdir(), get_configdir(), get_logdir(), get_cachedir(), get_libdir(),
get_datadir(), get_execdir(), get_langdir(), get_piddir()); get_datadir(), get_execdir(), get_langdir(), get_piddir(),
get_config_persistdir());
} }
@ -1229,6 +1233,12 @@ bool set_dirs(const char *basedir)
set_piddir(path); set_piddir(path);
} }
if (rv && (rv = handle_path_arg(&path, basedir, MXS_DEFAULT_DATA_SUBPATH "/"
MXS_DEFAULT_CONFIG_PERSIST_SUBPATH, true, true)))
{
set_config_persistdir(path);
}
return rv; return rv;
} }
@ -1327,7 +1337,7 @@ int main(int argc, char **argv)
} }
} }
while ((opt = getopt_long(argc, argv, "dcf:l:vVs:S:?L:D:C:B:U:A:P:G:N:E:", while ((opt = getopt_long(argc, argv, "dcf:l:vVs:S:?L:D:C:B:U:A:P:G:N:E:F:",
long_options, &option_index)) != -1) long_options, &option_index)) != -1)
{ {
bool succp = true; bool succp = true;
@ -1477,6 +1487,16 @@ int main(int argc, char **argv)
succp = false; succp = false;
} }
break; break;
case 'F':
if (handle_path_arg(&tmp_path, optarg, NULL, true, true))
{
set_config_persistdir(tmp_path);
}
else
{
succp = false;
}
break;
case 'R': case 'R':
if (handle_path_arg(&tmp_path, optarg, NULL, true, false)) if (handle_path_arg(&tmp_path, optarg, NULL, true, false))
{ {
@ -2524,6 +2544,20 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
} }
} }
} }
else if (strcmp(name, "persistdir") == 0)
{
if (strcmp(get_config_persistdir(), default_config_persistdir) == 0)
{
if (handle_path_arg((char**)&tmp, (char*)value, NULL, true, false))
{
set_config_persistdir(tmp);
}
else
{
return 0;
}
}
}
else if (strcmp(name, "syslog") == 0) else if (strcmp(name, "syslog") == 0)
{ {
if (!syslog_configured) if (!syslog_configured)