From 9928cd645f6ccacd88b975c0f348ccf16cdd74e4 Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Mon, 30 Dec 2013 17:20:39 +0100 Subject: [PATCH] added local config --- CHANGELOG | 6 ++++++ arangosh/ArangoShell/ArangoClient.cpp | 14 ++++++++++++++ lib/ApplicationServer/ApplicationServer.cpp | 20 +++++++++++++++++++- lib/ApplicationServer/ApplicationServer.h | 12 ++++++++---- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4950a3707d..615f40c9b5 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +v1.4.5 (XXXX-XX-XX) +------------------- + +* added override file "arangod.conf.local" (and co) + + v1.4.4 (2013-12-24) ------------------- diff --git a/arangosh/ArangoShell/ArangoClient.cpp b/arangosh/ArangoShell/ArangoClient.cpp index 96ba825144..4ff1d1e1e8 100644 --- a/arangosh/ArangoShell/ArangoClient.cpp +++ b/arangosh/ArangoShell/ArangoClient.cpp @@ -280,6 +280,7 @@ void ArangoClient::parse (ProgramOptions& options, // parse config file string configFile = ""; + bool allowLocal = false; if (! _configFile.empty()) { if (StringUtils::tolower(_configFile) == string("none")) { @@ -300,6 +301,7 @@ void ArangoClient::parse (ProgramOptions& options, if (FileUtils::exists(sysDir)) { configFile = sysDir; + allowLocal = true; } else { LOGGER_DEBUG("no system init file '" << sysDir << "'"); @@ -308,6 +310,18 @@ void ArangoClient::parse (ProgramOptions& options, } if (! configFile.empty()) { + if (allowLocal) { + string localConfigFile = configFile + ".local"; + + if (FileUtils::exists(localConfigFile)) { + LOGGER_DEBUG("using init override file '" << localConfigFile << "'"); + + if (! options.parse(description, localConfigFile)) { + LOGGER_FATAL_AND_EXIT("cannot parse config file '" << localConfigFile << "': " << options.lastError()); + } + } + } + LOGGER_DEBUG("using init file '" << configFile << "'"); if (! options.parse(description, configFile)) { diff --git a/lib/ApplicationServer/ApplicationServer.cpp b/lib/ApplicationServer/ApplicationServer.cpp index 11b1dde333..40b806c786 100644 --- a/lib/ApplicationServer/ApplicationServer.cpp +++ b/lib/ApplicationServer/ApplicationServer.cpp @@ -1004,8 +1004,27 @@ bool ApplicationServer::readConfigurationFile () { if (d != 0) { string sysDir = string(d) + _systemConfigFile; + string localSysDir = sysDir + ".local"; + TRI_FreeString(TRI_CORE_MEM_ZONE, d); + // check and see if a local override file exists + if (FileUtils::exists(localSysDir)) { + LOGGER_INFO("using init override file '" << localSysDir << "'"); + + bool ok = _options.parse(_descriptionFile, localSysDir); + + // Observe that this is treated as an error - the configuration file exists + // but for some reason can not be parsed. Best to report an error. + if (! ok) { + LOGGER_ERROR("cannot parse config file '" << localSysDir << "': " << _options.lastError()); + return ok; + } + } + else { + LOGGER_TRACE("no system init override file '" << sysDir << "' found"); + } + // check and see if file exists if (FileUtils::exists(sysDir)) { LOGGER_INFO("using init file '" << sysDir << "'"); @@ -1014,7 +1033,6 @@ bool ApplicationServer::readConfigurationFile () { // Observe that this is treated as an error - the configuration file exists // but for some reason can not be parsed. Best to report an error. - if (! ok) { LOGGER_ERROR("cannot parse config file '" << sysDir << "': " << _options.lastError()); } diff --git a/lib/ApplicationServer/ApplicationServer.h b/lib/ApplicationServer/ApplicationServer.h index 563c0d7578..f43168edc7 100644 --- a/lib/ApplicationServer/ApplicationServer.h +++ b/lib/ApplicationServer/ApplicationServer.h @@ -422,14 +422,18 @@ namespace triagens { /// Specifies the name of the configuration file to use. /// /// If this command is not passed to the server, then by default, the server -/// will attempt to first locate a file named @LIT{~/.arango/arangod.conf} in the +/// will attempt to first locate a file named `~/.arango/arangod.conf` in the /// user's home directory. /// /// If no such file is found, the server will proceed to look for a file -/// @LIT{arangod.conf} in the system configuration directory. The system +/// `arangod.conf` in the system configuration directory. The system /// configuration directory is platform-specific, and may be changed when -/// compiling ArangoDB yourself. It may default to @LIT{/etc} or -/// @LIT{/usr/local/etc}. +/// compiling ArangoDB yourself. It may default to `/etc/arangodb` or +/// `/usr/local/etc/arangodb`. This file is installed when using a package +/// manager like rpm or dpkg. If you modify this file and later upgrade to a new +/// version of ArangoDB, then the package manager normally warns you about the +/// conflict. In order to avoid these warning for small adjustments, you can put +/// local overrides into a file `arangod.conf.local`. /// /// Only command line options with a value should be set within the /// configuration file. Command line options which act as flags should be