mirror of https://gitee.com/bigwinds/arangodb
fix path to node_modules after copying files (#7086)
This commit is contained in:
parent
937a7eee5f
commit
011d264e98
|
@ -115,7 +115,6 @@ V8DealerFeature::V8DealerFeature(
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8DealerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
void V8DealerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
|
||||||
options->addSection("javascript", "Configure the Javascript engine");
|
options->addSection("javascript", "Configure the Javascript engine");
|
||||||
|
|
||||||
options->addHiddenOption(
|
options->addHiddenOption(
|
||||||
|
@ -260,10 +259,28 @@ void V8DealerFeature::prepare() {
|
||||||
void V8DealerFeature::start() {
|
void V8DealerFeature::start() {
|
||||||
if (_copyInstallation) {
|
if (_copyInstallation) {
|
||||||
copyInstallationFiles(); // will exit process if it fails
|
copyInstallationFiles(); // will exit process if it fails
|
||||||
|
} else {
|
||||||
|
// don't copy JS files on startup
|
||||||
|
// now check if we have a js directory inside the database directory, and if it looks good
|
||||||
|
auto dbPathFeature = application_features::ApplicationServer::getFeature<DatabasePathFeature>(DatabasePathFeature::name());
|
||||||
|
const std::string dbJSPath = FileUtils::buildFilename(dbPathFeature->directory(), "js");
|
||||||
|
const std::string checksumFile = FileUtils::buildFilename(dbJSPath, StaticStrings::checksumFileJs);
|
||||||
|
const std::string serverPath = FileUtils::buildFilename(dbJSPath, "server");
|
||||||
|
const std::string commonPath = FileUtils::buildFilename(dbJSPath, "common");
|
||||||
|
if (FileUtils::isDirectory(dbJSPath) &&
|
||||||
|
FileUtils::exists(checksumFile) &&
|
||||||
|
FileUtils::isDirectory(serverPath) &&
|
||||||
|
FileUtils::isDirectory(commonPath)) {
|
||||||
|
// only load node modules from original startup path
|
||||||
|
_nodeModulesDirectory = _startupDirectory;
|
||||||
|
// js directory inside database directory looks good. now use it!
|
||||||
|
_startupDirectory = dbJSPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::V8) << "effective startup-directory is '" << _startupDirectory <<
|
LOG_TOPIC(DEBUG, Logger::V8) << "effective startup-directory: " << _startupDirectory <<
|
||||||
"', effective module-directories are " << _moduleDirectories;
|
", effective module-directories: " << _moduleDirectories <<
|
||||||
|
", node-modules-directory: " << _nodeModulesDirectory;
|
||||||
|
|
||||||
_startupLoader.setDirectory(_startupDirectory);
|
_startupLoader.setDirectory(_startupDirectory);
|
||||||
ServerState::instance()->setJavaScriptPath(_startupDirectory);
|
ServerState::instance()->setJavaScriptPath(_startupDirectory);
|
||||||
|
@ -282,7 +299,6 @@ void V8DealerFeature::start() {
|
||||||
if (!_appPath.empty()) {
|
if (!_appPath.empty()) {
|
||||||
paths.push_back(std::string("application '" + _appPath + "'"));
|
paths.push_back(std::string("application '" + _appPath + "'"));
|
||||||
|
|
||||||
|
|
||||||
// create app directory if it does not exist
|
// create app directory if it does not exist
|
||||||
if (!basics::FileUtils::isDirectory(_appPath)) {
|
if (!basics::FileUtils::isDirectory(_appPath)) {
|
||||||
std::string systemErrorStr;
|
std::string systemErrorStr;
|
||||||
|
@ -383,6 +399,7 @@ void V8DealerFeature::copyInstallationFiles() {
|
||||||
// these do not need JavaScript support
|
// these do not need JavaScript support
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get base path from DatabasePathFeature
|
// get base path from DatabasePathFeature
|
||||||
auto dbPathFeature = application_features::ApplicationServer::getFeature<DatabasePathFeature>();
|
auto dbPathFeature = application_features::ApplicationServer::getFeature<DatabasePathFeature>();
|
||||||
const std::string copyJSPath = FileUtils::buildFilename(dbPathFeature->directory(), "js");
|
const std::string copyJSPath = FileUtils::buildFilename(dbPathFeature->directory(), "js");
|
||||||
|
@ -393,6 +410,8 @@ void V8DealerFeature::copyInstallationFiles() {
|
||||||
}
|
}
|
||||||
TRI_ASSERT(!copyJSPath.empty());
|
TRI_ASSERT(!copyJSPath.empty());
|
||||||
|
|
||||||
|
_nodeModulesDirectory = _startupDirectory;
|
||||||
|
|
||||||
const std::string checksumFile = FileUtils::buildFilename(_startupDirectory, StaticStrings::checksumFileJs);
|
const std::string checksumFile = FileUtils::buildFilename(_startupDirectory, StaticStrings::checksumFileJs);
|
||||||
const std::string copyChecksumFile = FileUtils::buildFilename(copyJSPath, StaticStrings::checksumFileJs);
|
const std::string copyChecksumFile = FileUtils::buildFilename(copyJSPath, StaticStrings::checksumFileJs);
|
||||||
|
|
||||||
|
@ -450,7 +469,6 @@ void V8DealerFeature::copyInstallationFiles() {
|
||||||
if (normalized.substr(normalized.size() - nodeModulesPath.size(), nodeModulesPath.size()) == nodeModulesPath ||
|
if (normalized.substr(normalized.size() - nodeModulesPath.size(), nodeModulesPath.size()) == nodeModulesPath ||
|
||||||
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(), nodeModulesPathVersioned.size()) == nodeModulesPathVersioned) {
|
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(), nodeModulesPathVersioned.size()) == nodeModulesPathVersioned) {
|
||||||
// filter it out!
|
// filter it out!
|
||||||
_nodeModulesDirectory = _startupDirectory;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1398,7 +1416,7 @@ V8Context* V8DealerFeature::buildContext(size_t id) {
|
||||||
directories.insert(directories.end(), _moduleDirectories.begin(),
|
directories.insert(directories.end(), _moduleDirectories.begin(),
|
||||||
_moduleDirectories.end());
|
_moduleDirectories.end());
|
||||||
directories.emplace_back(_startupDirectory);
|
directories.emplace_back(_startupDirectory);
|
||||||
if (!_nodeModulesDirectory.empty()) {
|
if (!_nodeModulesDirectory.empty() && _nodeModulesDirectory != _startupDirectory) {
|
||||||
directories.emplace_back(_nodeModulesDirectory);
|
directories.emplace_back(_nodeModulesDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,8 @@ void V8ShellFeature::copyInstallationFiles() {
|
||||||
LOG_TOPIC(DEBUG, Logger::V8) << "Copying JS installation files from '" << _startupDirectory << "' to '" << _copyDirectory << "'";
|
LOG_TOPIC(DEBUG, Logger::V8) << "Copying JS installation files from '" << _startupDirectory << "' to '" << _copyDirectory << "'";
|
||||||
int res = TRI_ERROR_NO_ERROR;
|
int res = TRI_ERROR_NO_ERROR;
|
||||||
|
|
||||||
|
_nodeModulesDirectory = _startupDirectory;
|
||||||
|
|
||||||
if (FileUtils::exists(_copyDirectory)) {
|
if (FileUtils::exists(_copyDirectory)) {
|
||||||
res = TRI_RemoveDirectory(_copyDirectory.c_str());
|
res = TRI_RemoveDirectory(_copyDirectory.c_str());
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
|
@ -270,7 +272,6 @@ void V8ShellFeature::copyInstallationFiles() {
|
||||||
if (normalized.substr(normalized.size() - nodeModulesPath.size(), nodeModulesPath.size()) == nodeModulesPath ||
|
if (normalized.substr(normalized.size() - nodeModulesPath.size(), nodeModulesPath.size()) == nodeModulesPath ||
|
||||||
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(), nodeModulesPathVersioned.size()) == nodeModulesPathVersioned) {
|
normalized.substr(normalized.size() - nodeModulesPathVersioned.size(), nodeModulesPathVersioned.size()) == nodeModulesPathVersioned) {
|
||||||
// filter it out!
|
// filter it out!
|
||||||
_nodeModulesDirectory = _startupDirectory;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue