Fixed custom directory locations not working.
This commit is contained in:
parent
6cef7ab8cc
commit
710cfbd6c5
@ -1178,7 +1178,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
case 'D':
|
||||
sprintf(datadir,"%s",optarg);
|
||||
maxscaledatadir = strdup(optarg);
|
||||
set_datadir(strdup(optarg));
|
||||
datadir_defined = true;
|
||||
break;
|
||||
case 'C':
|
||||
@ -1190,13 +1190,13 @@ int main(int argc, char **argv)
|
||||
case 'B':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,false))
|
||||
{
|
||||
libdir = tmp_path;
|
||||
set_libdir(tmp_path);
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,true))
|
||||
{
|
||||
cachedir = tmp_path;
|
||||
set_cachedir(tmp_path);
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
@ -1552,12 +1552,9 @@ int main(int argc, char **argv)
|
||||
|
||||
ini_parse(cnf_file_path,cnf_preparser,NULL);
|
||||
|
||||
if(!datadir_defined)
|
||||
sprintf(datadir,"%s",default_datadir);
|
||||
|
||||
|
||||
/** Use the cache dir for the mysql folder of the embedded library */
|
||||
sprintf(mysql_home, "%s/mysql", cachedir?cachedir:default_cachedir);
|
||||
sprintf(mysql_home, "%s/mysql", get_cachedir());
|
||||
setenv("MYSQL_HOME", mysql_home, 1);
|
||||
|
||||
|
||||
@ -1628,42 +1625,33 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(cachedir == NULL)
|
||||
cachedir = strdup(default_cachedir);
|
||||
if(langdir == NULL)
|
||||
langdir = strdup(default_langdir);
|
||||
if(libdir == NULL)
|
||||
libdir = strdup(default_libdir);
|
||||
/**
|
||||
/*
|
||||
* Set a data directory for the mysqld library, we use
|
||||
* a unique directory name to avoid clauses if multiple
|
||||
* instances of the gateway are being run on the same
|
||||
* machine.
|
||||
*/
|
||||
|
||||
if(datadir[strlen(datadir)-1] != '/')
|
||||
strcat(datadir,"/");
|
||||
strcat(datadir,"data");
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
sprintf(datadir,"%s/data",get_datadir());
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
if(errno != EEXIST){
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(datadir, "%s/data%d", datadir, getpid());
|
||||
sprintf(datadir, "%s/data/data%d", get_datadir(), getpid());
|
||||
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
if(errno != EEXIST){
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create data directory '%s': %d %s\n",datadir,errno,strerror(errno));
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
|
||||
if (!daemon_mode)
|
||||
{
|
||||
@ -1676,8 +1664,8 @@ int main(int argc, char **argv)
|
||||
cnf_file_path,
|
||||
logdir,
|
||||
datadir,
|
||||
libdir,
|
||||
cachedir);
|
||||
get_libdir(),
|
||||
get_cachedir());
|
||||
}
|
||||
|
||||
LOGIF(LM,
|
||||
@ -1698,11 +1686,11 @@ int main(int argc, char **argv)
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(LOGFILE_MESSAGE,
|
||||
"Module directory: %s",
|
||||
libdir)));
|
||||
get_libdir())));
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(LOGFILE_MESSAGE,
|
||||
"Service cache: %s",
|
||||
cachedir)));
|
||||
get_cachedir())));
|
||||
|
||||
/*< Update the server options */
|
||||
for (i = 0; server_options[i]; i++)
|
||||
@ -1717,7 +1705,7 @@ int main(int argc, char **argv)
|
||||
snprintf(language_arg,
|
||||
11+PATH_MAX+1,
|
||||
"--language=%s",
|
||||
langdir);
|
||||
langdir?langdir:default_langdir);
|
||||
server_options[i] = language_arg;
|
||||
}
|
||||
}
|
||||
@ -1773,9 +1761,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
libmysqld_started = TRUE;
|
||||
|
||||
if(libdir == NULL)
|
||||
libdir = strdup(default_libdir);
|
||||
|
||||
if (!config_load(cnf_file_path))
|
||||
{
|
||||
char* fprerr = "Failed to load MaxScale configuration "
|
||||
@ -2080,7 +2065,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
|
||||
|
||||
char pathbuffer[PATH_MAX];
|
||||
char* errstr;
|
||||
|
||||
char *tmp;
|
||||
/** These are read from the configuration file. These will not override
|
||||
* command line parameters but will override default values. */
|
||||
if(strcasecmp(section,"maxscale") == 0)
|
||||
@ -2092,8 +2077,11 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
|
||||
}
|
||||
else if(strcmp(name, "libdir") == 0)
|
||||
{
|
||||
if(libdir == NULL)
|
||||
handle_path_arg(&libdir,(char*)value,NULL,true,false);
|
||||
if(get_libdir() == default_libdir )
|
||||
{
|
||||
handle_path_arg(&tmp,(char*)value,NULL,true,false);
|
||||
set_libdir(tmp);
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "piddir") == 0)
|
||||
{
|
||||
@ -2108,16 +2096,18 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
|
||||
if(handle_path_arg(&tmp,(char*)value,NULL,true,false))
|
||||
{
|
||||
sprintf(datadir,"%s",tmp);
|
||||
maxscaledatadir = strdup(tmp);
|
||||
set_datadir(tmp);
|
||||
datadir_defined = true;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "cachedir") == 0)
|
||||
{
|
||||
if(cachedir == NULL)
|
||||
handle_path_arg((char**)&cachedir,(char*)value,NULL,true,false);
|
||||
if(get_cachedir() == default_cachedir)
|
||||
{
|
||||
handle_path_arg((char**)&tmp,(char*)value,NULL,true,false);
|
||||
set_cachedir(tmp);
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "language") == 0)
|
||||
{
|
||||
|
@ -9,6 +9,12 @@ char* get_libdir()
|
||||
return libdir?libdir:(char*)default_libdir;
|
||||
}
|
||||
|
||||
void set_libdir(char* param)
|
||||
{
|
||||
if(libdir)
|
||||
free(libdir);
|
||||
libdir = param;
|
||||
}
|
||||
/**
|
||||
* Get the service cache directory
|
||||
* @return The path to the cache directory
|
||||
@ -18,6 +24,12 @@ char* get_cachedir()
|
||||
return cachedir?cachedir:(char*)default_cachedir;
|
||||
}
|
||||
|
||||
void set_cachedir(char* param)
|
||||
{
|
||||
if(cachedir)
|
||||
free(cachedir);
|
||||
cachedir = param;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service cache directory
|
||||
@ -27,3 +39,10 @@ char* get_datadir()
|
||||
{
|
||||
return maxscaledatadir?maxscaledatadir:(char*)default_datadir;
|
||||
}
|
||||
|
||||
void set_datadir(char* param)
|
||||
{
|
||||
if(maxscaledatadir)
|
||||
free(maxscaledatadir);
|
||||
maxscaledatadir = param;
|
||||
}
|
@ -25,15 +25,15 @@
|
||||
#include <string.h>
|
||||
/** Default file locations, configured by CMake */
|
||||
static const char* default_cnf_fname = "maxscale.cnf";
|
||||
static const char* default_configdir = "/etc/";
|
||||
static const char* default_piddir = "@MAXSCALE_VARDIR@/run/maxscale/"; /*< This should be changed to just /run eventually,
|
||||
static const char* default_configdir = "/etc";
|
||||
static const char* default_piddir = "@MAXSCALE_VARDIR@/run/maxscale"; /*< This should be changed to just /run eventually,
|
||||
* the /var/run folder is an old standard and the newe FSH 3.0
|
||||
* uses /run for PID files.*/
|
||||
static const char* default_logdir = "@MAXSCALE_VARDIR@/log/maxscale/";
|
||||
static const char* default_datadir = "@MAXSCALE_VARDIR@/lib/maxscale/";
|
||||
static const char* default_logdir = "@MAXSCALE_VARDIR@/log/maxscale";
|
||||
static const char* default_datadir = "@MAXSCALE_VARDIR@/lib/maxscale";
|
||||
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
|
||||
static const char* default_cachedir = "@MAXSCALE_VARDIR@/cache/maxscale/";
|
||||
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/";
|
||||
static const char* default_cachedir = "@MAXSCALE_VARDIR@/cache/maxscale";
|
||||
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale";
|
||||
|
||||
static char* configdir = NULL;
|
||||
static char* logdir = NULL;
|
||||
@ -42,6 +42,9 @@ static char* cachedir = NULL;
|
||||
static char* maxscaledatadir = NULL;
|
||||
static char* langdir = NULL;
|
||||
static char* piddir = NULL;
|
||||
void set_libdir(char* param);
|
||||
void set_datadir(char* param);
|
||||
void set_cachedir(char* param);
|
||||
char* get_libdir();
|
||||
char* get_datadir();
|
||||
char* get_cachedir();
|
||||
|
Loading…
x
Reference in New Issue
Block a user