mirror of https://gitee.com/bigwinds/arangodb
Implement scheme to more clever pass the directories from the build process to the run-time
We will now try to evaluate the toplevel install directory from the configured binary dir. We will use this toplever directory when searching for other directories.
This commit is contained in:
parent
71db758e35
commit
1f162ac882
|
@ -568,6 +568,8 @@ if (WIN32)
|
||||||
DESTINATION "bin/share/arangodb/"
|
DESTINATION "bin/share/arangodb/"
|
||||||
RENAME ${ICU_DT_DEST})
|
RENAME ${ICU_DT_DEST})
|
||||||
else()
|
else()
|
||||||
|
# other platforms don't install ICU:
|
||||||
|
set(ICU_DT_DEST "" PARENT_SCOPE)
|
||||||
add_custom_target(nonthinV8
|
add_custom_target(nonthinV8
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../../Installation/archive-de-thinner.sh ${V8_REL_TARGET_PATH}
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../../Installation/archive-de-thinner.sh ${V8_REL_TARGET_PATH}
|
||||||
COMMENT de-thins V8 .a files)
|
COMMENT de-thins V8 .a files)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "DatabaseFeature.h"
|
#include "DatabaseFeature.h"
|
||||||
|
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Cluster/ServerState.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "Cluster/v8-cluster.h"
|
#include "Cluster/v8-cluster.h"
|
||||||
#include "GeneralServer/GeneralServerFeature.h"
|
#include "GeneralServer/GeneralServerFeature.h"
|
||||||
|
@ -129,6 +130,15 @@ void DatabaseFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
// strip trailing separators
|
// strip trailing separators
|
||||||
_databasePath = StringUtils::rTrim(_directory, TRI_DIR_SEPARATOR_STR);
|
_databasePath = StringUtils::rTrim(_directory, TRI_DIR_SEPARATOR_STR);
|
||||||
|
|
||||||
|
auto ctx = ArangoGlobalContext::CONTEXT;
|
||||||
|
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
LOG(ERR) << "failed to get global context. ";
|
||||||
|
FATAL_ERROR_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->getCheckPath(_databasePath, "database.directory");
|
||||||
|
|
||||||
if (_maximalJournalSize < TRI_JOURNAL_MINIMAL_SIZE) {
|
if (_maximalJournalSize < TRI_JOURNAL_MINIMAL_SIZE) {
|
||||||
LOG(FATAL) << "invalid value for '--database.maximal-journal-size'. "
|
LOG(FATAL) << "invalid value for '--database.maximal-journal-size'. "
|
||||||
"expected at least "
|
"expected at least "
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
#include "Basics/tri-strings.h"
|
#include "Basics/tri-strings.h"
|
||||||
|
|
||||||
#include "Actions/ActionFeature.h"
|
#include "Actions/ActionFeature.h"
|
||||||
|
@ -80,7 +81,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::wal;
|
using namespace arangodb::wal;
|
||||||
|
|
||||||
static int runServer(int argc, char** argv) {
|
static int runServer(int argc, char** argv) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, SBIN_DIRECTORY);
|
||||||
context.installSegv();
|
context.installSegv();
|
||||||
context.runStartupChecks();
|
context.runStartupChecks();
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "Basics/ConditionLocker.h"
|
#include "Basics/ConditionLocker.h"
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
#include "Basics/WorkMonitor.h"
|
#include "Basics/WorkMonitor.h"
|
||||||
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Cluster/ServerState.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "Dispatcher/DispatcherFeature.h"
|
#include "Dispatcher/DispatcherFeature.h"
|
||||||
#include "Dispatcher/DispatcherThread.h"
|
#include "Dispatcher/DispatcherThread.h"
|
||||||
|
@ -147,6 +148,15 @@ void V8DealerFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
// remove trailing / from path and set path
|
// remove trailing / from path and set path
|
||||||
_startupPath = StringUtils::rTrim(_startupPath, TRI_DIR_SEPARATOR_STR);
|
_startupPath = StringUtils::rTrim(_startupPath, TRI_DIR_SEPARATOR_STR);
|
||||||
|
|
||||||
|
auto ctx = ArangoGlobalContext::CONTEXT;
|
||||||
|
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
LOG(ERR) << "failed to get global context. ";
|
||||||
|
FATAL_ERROR_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->getCheckPath(_startupPath, "javascript.startup-directory");
|
||||||
|
|
||||||
_startupLoader.setDirectory(_startupPath);
|
_startupLoader.setDirectory(_startupPath);
|
||||||
ServerState::instance()->setJavaScriptPath(_startupPath);
|
ServerState::instance()->setJavaScriptPath(_startupPath);
|
||||||
|
|
||||||
|
@ -156,6 +166,8 @@ void V8DealerFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
FATAL_ERROR_EXIT();
|
FATAL_ERROR_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->getCheckPath(_appPath, "javascript.app-directory");
|
||||||
|
|
||||||
// use a minimum of 1 second for GC
|
// use a minimum of 1 second for GC
|
||||||
if (_gcFrequency < 1) {
|
if (_gcFrequency < 1) {
|
||||||
_gcFrequency = 1;
|
_gcFrequency = 1;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/ShutdownFeature.h"
|
#include "ApplicationFeatures/ShutdownFeature.h"
|
||||||
|
@ -41,7 +42,7 @@ using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/ShutdownFeature.h"
|
#include "ApplicationFeatures/ShutdownFeature.h"
|
||||||
|
@ -38,7 +39,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/ShutdownFeature.h"
|
#include "ApplicationFeatures/ShutdownFeature.h"
|
||||||
|
@ -39,7 +40,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/ShutdownFeature.h"
|
#include "ApplicationFeatures/ShutdownFeature.h"
|
||||||
|
@ -39,7 +40,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
#include "Basics/Utf8Helper.h"
|
#include "Basics/Utf8Helper.h"
|
||||||
#include "Basics/shell-colors.h"
|
#include "Basics/shell-colors.h"
|
||||||
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
|
@ -809,6 +810,15 @@ void V8ShellFeature::initGlobals() {
|
||||||
TRI_V8_ASCII_STRING2(_isolate, "ARANGO_QUIET"),
|
TRI_V8_ASCII_STRING2(_isolate, "ARANGO_QUIET"),
|
||||||
v8::Boolean::New(_isolate, _console->quiet()));
|
v8::Boolean::New(_isolate, _console->quiet()));
|
||||||
|
|
||||||
|
auto ctx = ArangoGlobalContext::CONTEXT;
|
||||||
|
|
||||||
|
if (ctx == nullptr) {
|
||||||
|
LOG(ERR) << "failed to get global context. ";
|
||||||
|
FATAL_ERROR_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->getCheckPath(_startupDirectory, "javascript.startup-directory");
|
||||||
|
|
||||||
// initialize standard modules
|
// initialize standard modules
|
||||||
std::string modules =
|
std::string modules =
|
||||||
FileUtils::buildFilename(_startupDirectory, "client/modules") + ";" +
|
FileUtils::buildFilename(_startupDirectory, "client/modules") + ";" +
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/LanguageFeature.h"
|
#include "ApplicationFeatures/LanguageFeature.h"
|
||||||
|
@ -43,7 +44,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::string name = context.binaryName();
|
std::string name = context.binaryName();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ConfigFeature.h"
|
#include "ApplicationFeatures/ConfigFeature.h"
|
||||||
#include "ApplicationFeatures/ShutdownFeature.h"
|
#include "ApplicationFeatures/ShutdownFeature.h"
|
||||||
|
@ -36,7 +37,7 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ArangoGlobalContext context(argc, argv);
|
ArangoGlobalContext context(argc, argv, BIN_DIRECTORY);
|
||||||
context.installHup();
|
context.installHup();
|
||||||
|
|
||||||
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
std::shared_ptr<options::ProgramOptions> options(new options::ProgramOptions(
|
||||||
|
|
|
@ -17,8 +17,6 @@ set(CMAKE_INSTALL_SYSCONFDIR_ARANGO "${CMAKE_INSTALL_SYSCONFDIR}/arangodb3")
|
||||||
set(CMAKE_INSTALL_FULL_SYSCONFDIR_ARANGO "${CMAKE_INSTALL_FULL_SYSCONFDIR}/arangodb3")
|
set(CMAKE_INSTALL_FULL_SYSCONFDIR_ARANGO "${CMAKE_INSTALL_FULL_SYSCONFDIR}/arangodb3")
|
||||||
|
|
||||||
file(TO_NATIVE_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR_ARANGO}" ETCDIR_NATIVE)
|
file(TO_NATIVE_PATH "${CMAKE_INSTALL_FULL_SYSCONFDIR_ARANGO}" ETCDIR_NATIVE)
|
||||||
STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ETCDIR_ESCAPED "${ETCDIR_NATIVE}")
|
|
||||||
add_definitions("-D_SYSCONFDIR_=\"${ETCDIR_ESCAPED}\"")
|
|
||||||
|
|
||||||
# database directory
|
# database directory
|
||||||
FILE(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/var/lib/arangodb3")
|
FILE(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/var/lib/arangodb3")
|
||||||
|
@ -84,6 +82,15 @@ install(
|
||||||
DIRECTORY ${PROJECT_BINARY_DIR}/var/lib/arangodb3-apps
|
DIRECTORY ${PROJECT_BINARY_DIR}/var/lib/arangodb3-apps
|
||||||
DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib)
|
DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib)
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### @brief propagate the locations into our programms:
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
configure_file (
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/lib/Basics/directories.h.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/Basics/directories.h"
|
||||||
|
NEWLINE_STYLE UNIX
|
||||||
|
)
|
||||||
|
|
||||||
# sub directories --------------------------------------------------------------
|
# sub directories --------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -106,8 +113,8 @@ install(
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
#get_cmake_property(_variableNames VARIABLES)
|
get_cmake_property(_variableNames VARIABLES)
|
||||||
#foreach (_variableName ${_variableNames})
|
foreach (_variableName ${_variableNames})
|
||||||
# message(STATUS "${_variableName}=${${_variableName}}")
|
message(STATUS "${_variableName}=${${_variableName}}")
|
||||||
#endforeach()
|
endforeach()
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -40,7 +40,7 @@ set(PROJECT_SOURCE_DIR @PROJECT_SOURCE_DIR@)
|
||||||
################################################################################
|
################################################################################
|
||||||
# Get the final values for cpack:
|
# Get the final values for cpack:
|
||||||
################################################################################
|
################################################################################
|
||||||
set(CPACK_GENERATOR "DEB")
|
set(CPACK_GENERATOR "RPM")
|
||||||
set(CPACK_PACKAGE_VERSION "${ARANGODB_VERSION}")
|
set(CPACK_PACKAGE_VERSION "${ARANGODB_VERSION}")
|
||||||
set(CPACK_PACKAGE_NAME "arangodb3-client")
|
set(CPACK_PACKAGE_NAME "arangodb3-client")
|
||||||
set(CPACK_PACKAGE_CONTACT ${ARANGODB_PACKAGE_CONTACT})
|
set(CPACK_PACKAGE_CONTACT ${ARANGODB_PACKAGE_CONTACT})
|
||||||
|
|
|
@ -24,8 +24,10 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "Basics/directories.h"
|
||||||
#include "Basics/FileUtils.h"
|
#include "Basics/FileUtils.h"
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "ProgramOptions/IniFileParser.h"
|
#include "ProgramOptions/IniFileParser.h"
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
|
@ -119,12 +121,22 @@ void ConfigFeature::loadConfigFile(std::shared_ptr<ProgramOptions> options,
|
||||||
//
|
//
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
auto context = ArangoGlobalContext::CONTEXT;
|
||||||
std::string basename = name + ".conf";
|
std::string basename = name + ".conf";
|
||||||
std::string filename =
|
std::string filename;
|
||||||
FileUtils::buildFilename(FileUtils::currentDirectory(), basename);
|
|
||||||
|
if (context != nullptr) {
|
||||||
|
filename = FileUtils::buildFilename(FileUtils::buildFilename(context->runRoot(), _SYSCONFDIR_), basename);
|
||||||
|
LOG_TOPIC(DEBUG, Logger::CONFIG) << "checking '" << filename << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename.length() == 0 || !FileUtils::exists(filename)) {
|
||||||
|
|
||||||
|
filename = FileUtils::buildFilename(FileUtils::currentDirectory(), basename);
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::CONFIG) << "checking '" << filename << "'";
|
LOG_TOPIC(DEBUG, Logger::CONFIG) << "checking '" << filename << "'";
|
||||||
|
|
||||||
|
|
||||||
if (!FileUtils::exists(filename)) {
|
if (!FileUtils::exists(filename)) {
|
||||||
filename = FileUtils::buildFilename(FileUtils::currentDirectory(),
|
filename = FileUtils::buildFilename(FileUtils::currentDirectory(),
|
||||||
"etc/relative/" + basename);
|
"etc/relative/" + basename);
|
||||||
|
@ -150,6 +162,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr<ProgramOptions> options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IniFileParser parser(options.get());
|
IniFileParser parser(options.get());
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,7 @@
|
||||||
|
|
||||||
#include "Basics/debugging.h"
|
#include "Basics/debugging.h"
|
||||||
#include "Basics/files.h"
|
#include "Basics/files.h"
|
||||||
#ifdef __arm__
|
|
||||||
#include "Basics/FileUtils.h"
|
#include "Basics/FileUtils.h"
|
||||||
#endif
|
|
||||||
#include "Logger/LogAppender.h"
|
#include "Logger/LogAppender.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "Rest/InitializeRest.h"
|
#include "Rest/InitializeRest.h"
|
||||||
|
@ -110,8 +108,11 @@ LONG CALLBACK unhandledExceptionHandler(EXCEPTION_POINTERS* e) {
|
||||||
|
|
||||||
ArangoGlobalContext* ArangoGlobalContext::CONTEXT = nullptr;
|
ArangoGlobalContext* ArangoGlobalContext::CONTEXT = nullptr;
|
||||||
|
|
||||||
ArangoGlobalContext::ArangoGlobalContext(int argc, char* argv[])
|
ArangoGlobalContext::ArangoGlobalContext(int argc, char* argv[], const char *InstallDirectory)
|
||||||
: _binaryName(TRI_BinaryName(argv[0])), _ret(EXIT_FAILURE), _useEventLog(true) {
|
: _binaryName(TRI_BinaryName(argv[0])),
|
||||||
|
_runRoot(TRI_GetInstallRoot(TRI_LocateBinaryPath(argv[0]), InstallDirectory)),
|
||||||
|
_ret(EXIT_FAILURE),
|
||||||
|
_useEventLog(true) {
|
||||||
|
|
||||||
static char const* serverName = "arangod";
|
static char const* serverName = "arangod";
|
||||||
if (_binaryName.size() < strlen(serverName) ||
|
if (_binaryName.size() < strlen(serverName) ||
|
||||||
|
@ -271,3 +272,15 @@ void ArangoGlobalContext::tempPathAvailable() {
|
||||||
"\\minidump_" + std::to_string(GetCurrentProcessId()) + ".dmp";
|
"\\minidump_" + std::to_string(GetCurrentProcessId()) + ".dmp";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArangoGlobalContext::getCheckPath(std::string &path, const char *whichPath) {
|
||||||
|
if (!arangodb::basics::FileUtils::exists(path)) {
|
||||||
|
std::string directory;
|
||||||
|
directory = arangodb::basics::FileUtils::buildFilename(_runRoot, path);
|
||||||
|
if (!arangodb::basics::FileUtils::exists(directory)) {
|
||||||
|
LOG(ERR) << "failed to locate " << whichPath << " directory, its neither available in '" << path << "' nor in '" << directory << "'";
|
||||||
|
FATAL_ERROR_EXIT();
|
||||||
|
}
|
||||||
|
path = directory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,11 +31,13 @@ class ArangoGlobalContext {
|
||||||
static ArangoGlobalContext* CONTEXT;
|
static ArangoGlobalContext* CONTEXT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArangoGlobalContext(int argc, char* argv[]);
|
ArangoGlobalContext(int argc, char* argv[], const char *InstallDirectory);
|
||||||
~ArangoGlobalContext();
|
~ArangoGlobalContext();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string binaryName() { return _binaryName; }
|
std::string binaryName() { return _binaryName; }
|
||||||
|
std::string runRoot() { return _runRoot; }
|
||||||
|
void getCheckPath(std::string &path, const char *whichPath);
|
||||||
int exit(int ret);
|
int exit(int ret);
|
||||||
void installHup();
|
void installHup();
|
||||||
void installSegv();
|
void installSegv();
|
||||||
|
@ -47,6 +49,7 @@ class ArangoGlobalContext {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _binaryName;
|
std::string _binaryName;
|
||||||
|
std::string _runRoot;
|
||||||
int _ret;
|
int _ret;
|
||||||
bool _useEventLog;
|
bool _useEventLog;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#define LOCCAL_STATE_DIR "@CMAKE_INSTALL_FULL_LOCALSTATEDIR@"
|
||||||
|
#define _SYSCONFDIR_ "@ETCDIR_NATIVE@"
|
||||||
|
#define STARTUP_DIRECTORY "@PKGDATADIR@/js"
|
||||||
|
#define DESTINATION_DIR "@CMAKE_INSTALL_DATAROOTDIR_ARANGO@/js"
|
||||||
|
#define ICU_DESTINATION_DIRECTORY "@ICU_DT_DEST@"
|
||||||
|
#define SBIN_DIRECTORY "@CMAKE_INSTALL_SBINDIR@"
|
||||||
|
#define BIN_DIRECTORY "@CMAKE_INSTALL_BINDIR@"
|
|
@ -27,6 +27,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Basics/directories.h"
|
||||||
#include "Basics/FileUtils.h"
|
#include "Basics/FileUtils.h"
|
||||||
#include "Basics/Mutex.h"
|
#include "Basics/Mutex.h"
|
||||||
#include "Basics/MutexLocker.h"
|
#include "Basics/MutexLocker.h"
|
||||||
|
@ -1647,6 +1648,9 @@ std::string TRI_LocateBinaryPath(char const* argv0) {
|
||||||
binaryPath = TRI_DuplicateString("");
|
binaryPath = TRI_DuplicateString("");
|
||||||
TRI_FreeString(TRI_CORE_MEM_ZONE, dir);
|
TRI_FreeString(TRI_CORE_MEM_ZONE, dir);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
binaryPath = dir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check PATH variable
|
// check PATH variable
|
||||||
|
@ -1693,6 +1697,34 @@ std::string TRI_LocateBinaryPath(char const* argv0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TRI_GetInstallRoot(std::string const& binaryPath,
|
||||||
|
char const *installBinaryPath) {
|
||||||
|
// First lets remove trailing (back) slashes from the bill:
|
||||||
|
long ibpLength = strlen(installBinaryPath);
|
||||||
|
|
||||||
|
if (installBinaryPath[ibpLength - 1] == TRI_DIR_SEPARATOR_CHAR) {
|
||||||
|
ibpLength --;
|
||||||
|
}
|
||||||
|
|
||||||
|
long bpLength = binaryPath.length();
|
||||||
|
const char *pbPath = binaryPath.c_str();
|
||||||
|
|
||||||
|
if (pbPath[bpLength - 1] == TRI_DIR_SEPARATOR_CHAR) {
|
||||||
|
bpLength --;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ibpLength > bpLength) {
|
||||||
|
return TRI_DIR_SEPARATOR_STR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < ibpLength; i ++) {
|
||||||
|
if (pbPath[bpLength -i] != installBinaryPath[ibpLength - i]) {
|
||||||
|
return TRI_DIR_SEPARATOR_STR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::string(pbPath, bpLength - ibpLength);
|
||||||
|
}
|
||||||
|
|
||||||
static bool CopyFileContents(int srcFD, int dstFD, ssize_t fileSize,
|
static bool CopyFileContents(int srcFD, int dstFD, ssize_t fileSize,
|
||||||
std::string& error) {
|
std::string& error) {
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
|
@ -2329,11 +2361,7 @@ char* TRI_LocateConfigDirectory() {
|
||||||
|
|
||||||
std::string r = TRI_LocateInstallDirectory();
|
std::string r = TRI_LocateInstallDirectory();
|
||||||
|
|
||||||
#ifdef _SYSCONFDIR_
|
|
||||||
r += _SYSCONFDIR_;
|
r += _SYSCONFDIR_;
|
||||||
#else
|
|
||||||
r += "etc\\arangodb3";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
r += std::string(1, TRI_DIR_SEPARATOR_CHAR);
|
r += std::string(1, TRI_DIR_SEPARATOR_CHAR);
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,16 @@ std::string TRI_BinaryName(char const* argv0);
|
||||||
|
|
||||||
std::string TRI_LocateBinaryPath(char const* argv0);
|
std::string TRI_LocateBinaryPath(char const* argv0);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief locates toplevel install directory
|
||||||
|
/// tries to substract InstallBinaryPath righthandside from binaryPath
|
||||||
|
/// (if equal) and returns either "/" if not, or the part of binaryPath
|
||||||
|
/// that is left of InstallBinaryPath:
|
||||||
|
/// /opt/usr/bin /usr/bin/ => /opt/
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string TRI_GetInstallRoot(std::string const& binaryPath, char const *installBinaryPath);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief locates the home directory
|
/// @brief locates the home directory
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "Basics/files.h"
|
#include "Basics/files.h"
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
#include "Basics/tri-strings.h"
|
#include "Basics/tri-strings.h"
|
||||||
|
#include "Basics/directories.h"
|
||||||
|
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
|
@ -319,7 +320,7 @@ void TRI_FixIcuDataEnv() {
|
||||||
std::string p = TRI_LocateInstallDirectory();
|
std::string p = TRI_LocateInstallDirectory();
|
||||||
|
|
||||||
if (!p.empty()) {
|
if (!p.empty()) {
|
||||||
std::string e = "ICU_DATA=" + p + "share\\arangodb3\\";
|
std::string e = "ICU_DATA=" + p + ICU_DESTINATION_DIRECTORY;
|
||||||
e = StringUtils::replace(e, "\\", "\\\\");
|
e = StringUtils::replace(e, "\\", "\\\\");
|
||||||
putenv(e.c_str());
|
putenv(e.c_str());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue