mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:arangodb/arangodb into devel
This commit is contained in:
commit
d8f19f3046
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "ApplicationFeatures/VersionFeature.h"
|
||||||
#include "Basics/ArangoGlobalContext.h"
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Basics/FileUtils.h"
|
#include "Basics/FileUtils.h"
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
|
@ -88,6 +89,15 @@ void ConfigFeature::loadConfigFile(std::shared_ptr<ProgramOptions> options,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fatal = true;
|
||||||
|
|
||||||
|
auto version = dynamic_cast<VersionFeature*>(
|
||||||
|
application_features::ApplicationServer::lookupFeature("Version"));
|
||||||
|
|
||||||
|
if (version != nullptr && version->printVersion()) {
|
||||||
|
fatal = false;
|
||||||
|
}
|
||||||
|
|
||||||
// always prefer an explicitly given config file
|
// always prefer an explicitly given config file
|
||||||
if (!_file.empty()) {
|
if (!_file.empty()) {
|
||||||
if (!FileUtils::exists(_file)) {
|
if (!FileUtils::exists(_file)) {
|
||||||
|
@ -189,8 +199,8 @@ void ConfigFeature::loadConfigFile(std::shared_ptr<ProgramOptions> options,
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::CONFIG) << "loading '" << filename << "'";
|
LOG_TOPIC(DEBUG, Logger::CONFIG) << "loading '" << filename << "'";
|
||||||
|
|
||||||
if (!parser.parse(filename)) {
|
if (filename.empty()) {
|
||||||
if (filename.empty()) {
|
if (fatal) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
std::string locationMsg = "(tried locations: ";
|
std::string locationMsg = "(tried locations: ";
|
||||||
for (auto const& it : locations) {
|
for (auto const& it : locations) {
|
||||||
|
@ -200,8 +210,14 @@ void ConfigFeature::loadConfigFile(std::shared_ptr<ProgramOptions> options,
|
||||||
locationMsg += "'" + FileUtils::buildFilename(it, basename) + "'";
|
locationMsg += "'" + FileUtils::buildFilename(it, basename) + "'";
|
||||||
}
|
}
|
||||||
locationMsg += ")";
|
locationMsg += ")";
|
||||||
options->failNotice(locationMsg);
|
options->failNotice("cannot find configuration file\n\n" + locationMsg);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parser.parse(filename)) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ class VersionFeature final : public application_features::ApplicationFeature {
|
||||||
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool printVersion() const { return _printVersion; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _printVersion;
|
bool _printVersion;
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,7 +65,8 @@ class IniFileParser {
|
||||||
// errors that occur during parse are reported to _options
|
// errors that occur during parse are reported to _options
|
||||||
bool parse(std::string const& filename) {
|
bool parse(std::string const& filename) {
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
return _options->fail("unable to open configuration file: no configuration file specified");
|
return _options->fail(
|
||||||
|
"unable to open configuration file: no configuration file specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream ifs(filename, std::ifstream::in);
|
std::ifstream ifs(filename, std::ifstream::in);
|
||||||
|
@ -130,7 +131,7 @@ class IniFileParser {
|
||||||
auto dn = basics::FileUtils::dirname(filename);
|
auto dn = basics::FileUtils::dirname(filename);
|
||||||
include = basics::FileUtils::buildFilename(dn, include);
|
include = basics::FileUtils::buildFilename(dn, include);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::CONFIG) << "reading include file '" << include
|
LOG_TOPIC(DEBUG, Logger::CONFIG) << "reading include file '" << include
|
||||||
<< "'";
|
<< "'";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue