char * bind_client_addr;
char * bind_backend_addr;
char server_address[SIRI_CFG_MAX_LEN_ADDRESS];
- char default_db_path[XPATH_MAX];
+ char db_path[XPATH_MAX];
char pipe_client_name[XPATH_MAX];
};
#define SIRIDB_VERSION_MAJOR 2
#define SIRIDB_VERSION_MINOR 0
-#define SIRIDB_VERSION_PATCH 42
+#define SIRIDB_VERSION_PATCH 43
/*
* Use SIRIDB_VERSION_PRE_RELEASE for alpha release versions.
* Note that debian alpha packages should use versions like this:
* 2.0.34-0alpha0
*/
-#define SIRIDB_VERSION_PRE_RELEASE ""
+#define SIRIDB_VERSION_PRE_RELEASE "-alpha-0"
#ifndef NDEBUG
#define SIRIDB_VERSION_BUILD_RELEASE "+debug"
#
# SiriDB will load databases from, and create databases in this location.
#
-default_db_path = /var/lib/siridb
+db_path = /var/lib/siridb
#
# SiriDB will run an optimize task each X seconds. A value of 0 (zero) disables
.shard_compression=0,
.shard_auto_duration=0,
.server_address="localhost",
- .default_db_path="",
+ .db_path="",
.pipe_support=0,
.pipe_client_name="siridb_client.sock",
.buffer_sync_interval=0,
const char * option_name,
char ** dest);
static void SIRI_CFG_read_pipe_client_name(cfgparser_t * cfgparser);
-static void SIRI_CFG_read_default_db_path(cfgparser_t * cfgparser);
+static void SIRI_CFG_read_db_path(cfgparser_t * cfgparser);
static void SIRI_CFG_read_max_open_files(cfgparser_t * cfgparser);
static void SIRI_CFG_read_ip_support(cfgparser_t * cfgparser);
static void SIRI_CFG_read_shard_compression(cfgparser_t * cfgparser);
&tmp);
siri_cfg.http_api_port = (uint16_t) tmp;
- SIRI_CFG_read_default_db_path(cfgparser);
+ SIRI_CFG_read_db_path(cfgparser);
SIRI_CFG_read_max_open_files(cfgparser);
SIRI_CFG_read_ip_support(cfgparser);
SIRI_CFG_read_shard_compression(cfgparser);
strcpy(siri_cfg.pipe_client_name, option->val->string);
}
-static void SIRI_CFG_read_default_db_path(cfgparser_t * cfgparser)
+static void SIRI_CFG_read_db_path(cfgparser_t * cfgparser)
{
cfgparser_option_t * option;
cfgparser_return_t rc;
&option,
cfgparser,
"siridb",
- "default_db_path");
+ "db_path");
if (rc != CFGPARSER_SUCCESS)
{
- return;
+ /* Fall-back using the old configuration name */
+ rc = cfgparser_get_option(
+ &option,
+ cfgparser,
+ "siridb",
+ "default_db_path");
+
+ if (rc != CFGPARSER_SUCCESS)
+ {
+ return;
+ }
}
if (option->tp != CFGPARSER_TP_STRING)
{
log_warning(
- "Error reading 'default_db_path' in '%s': %s.",
+ "Error reading 'db_path' in '%s': %s.",
siri.args->config,
"error: expecting a string value");
return;
if (strlen(option->val->string) >= XPATH_MAX)
{
log_warning(
- "Error reading 'default_db_path' in '%s': %s.",
+ "Error reading 'db_path' in '%s': %s.",
siri.args->config,
"error: path too long");
return;
}
- strncpy(siri_cfg.default_db_path, option->val->string, XPATH_MAX);
+ strncpy(siri_cfg.db_path, option->val->string, XPATH_MAX);
}
static void SIRI_CFG_read_max_open_files(cfgparser_t * cfgparser)
evars__bool(
"SIRIDB_ENABLE_SHARD_AUTO_DURATION",
&siri->cfg->shard_auto_duration);
+ evars__to_strn(
+ "SIRIDB_DB_PATH",
+ siri->cfg->db_path,
+ sizeof(siri->cfg->db_path));
+ /* Read old environment variable for backwards compatibility */
evars__to_strn(
"SIRIDB_DEFAULT_DB_PATH",
- siri->cfg->default_db_path,
- sizeof(siri->cfg->default_db_path));
+ siri->cfg->db_path,
+ sizeof(siri->cfg->db_path));
evars__u32_mm(
"SIRIDB_BUFFER_SYNC_INTERVAL",
&siri->cfg->buffer_sync_interval,
int rc = 0;
/* get service accounts file name */
- char fn[strlen(siri->cfg->default_db_path) + strlen(FILENAME) + 1];
+ char fn[strlen(siri->cfg->db_path) + strlen(FILENAME) + 1];
/* initialize linked list */
siri->accounts = llist_new();
}
/* make filename */
- sprintf(fn, "%s%s", siri->cfg->default_db_path, FILENAME);
+ sprintf(fn, "%s%s", siri->cfg->db_path, FILENAME);
if (!xpath_file_exist(fn))
{
qp_fpacker_t * fpacker;
/* get service accounts file name */
- char fn[strlen(siri->cfg->default_db_path) + strlen(FILENAME) + 1];
+ char fn[strlen(siri->cfg->db_path) + strlen(FILENAME) + 1];
/* make filename */
- sprintf(fn, "%s%s", siri->cfg->default_db_path, FILENAME);
+ sprintf(fn, "%s%s", siri->cfg->db_path, FILENAME);
if (
/* open a new account file */
return CPROTO_ERR_SERVICE; \
} \
\
- dbpath_len = strlen(siri.cfg->default_db_path) + qp_dbname.len + 2; \
+ dbpath_len = strlen(siri.cfg->db_path) + qp_dbname.len + 2; \
char dbpath[dbpath_len]; \
sprintf(dbpath, \
"%s%.*s/", \
- siri.cfg->default_db_path, \
+ siri.cfg->db_path, \
(int) qp_dbname.len, \
qp_dbname.via.raw); \
\
memset(tmppath, 0, XPATH_MAX);
- if (*siri.cfg->default_db_path == '\0')
+ if (*siri.cfg->db_path == '\0')
{
if (!homedir || !sysuser || strcmp(sysuser, "root") == 0)
{
- strcpy(siri.cfg->default_db_path, "/var/lib/siridb/");
+ strcpy(siri.cfg->db_path, "/var/lib/siridb/");
}
else
{
- snprintf(siri.cfg->default_db_path, XPATH_MAX, "%s%s.siridb/",
+ snprintf(siri.cfg->db_path, XPATH_MAX, "%s%s.siridb/",
homedir,
homedir[strlen(homedir)-1] == '/' ? "" : "/");
}
}
- if (!xpath_is_dir(siri.cfg->default_db_path))
+ if (!xpath_is_dir(siri.cfg->db_path))
{
log_warning("Database directory not found, creating directory '%s'.",
- siri.cfg->default_db_path);
- if (mkdir(siri.cfg->default_db_path, 0700) == -1)
+ siri.cfg->db_path);
+ if (mkdir(siri.cfg->db_path, 0700) == -1)
{
log_error("Cannot create directory '%s'.",
- siri.cfg->default_db_path);
+ siri.cfg->db_path);
return -1;
}
}
- if (realpath(siri.cfg->default_db_path, tmppath) == NULL)
+ if (realpath(siri.cfg->db_path, tmppath) == NULL)
{
log_warning(
"Could not resolve default database path: %s",
- siri.cfg->default_db_path);
+ siri.cfg->db_path);
}
else
{
- memcpy(siri.cfg->default_db_path, tmppath, sizeof(tmppath));
+ memcpy(siri.cfg->db_path, tmppath, sizeof(tmppath));
}
- len = strlen(siri.cfg->default_db_path);
+ len = strlen(siri.cfg->db_path);
if (len >= XPATH_MAX - 2)
{
}
/* add trailing slash (/) if its not already there */
- if (siri.cfg->default_db_path[len - 1] != '/')
+ if (siri.cfg->db_path[len - 1] != '/')
{
- siri.cfg->default_db_path[len] = '/';
- siri.cfg->default_db_path[len+1] = '\0';
+ siri.cfg->db_path[len] = '/';
+ siri.cfg->db_path[len+1] = '\0';
}
return 0;
struct dirent * dbpath;
char * buffer;
- if (!xpath_is_dir(siri.cfg->default_db_path))
+ if (!xpath_is_dir(siri.cfg->db_path))
{
log_warning("Database directory not found, creating directory '%s'.",
- siri.cfg->default_db_path);
- if (mkdir(siri.cfg->default_db_path, 0700) == -1)
+ siri.cfg->db_path);
+ if (mkdir(siri.cfg->db_path, 0700) == -1)
{
log_error("Cannot create directory '%s'.",
- siri.cfg->default_db_path);
+ siri.cfg->db_path);
return -1;
}
}
- if ((db_container_path = opendir(siri.cfg->default_db_path)) == NULL)
+ if ((db_container_path = opendir(siri.cfg->db_path)) == NULL)
{
log_error("Cannot open database directory '%s'.",
- siri.cfg->default_db_path);
+ siri.cfg->db_path);
return -1;
}
if (asprintf(
&buffer,
"%s%s/",
- siri.cfg->default_db_path,
+ siri.cfg->db_path,
dbpath->d_name) < 0)
{
/* allocation error occurred */