|
22 | 22 |
|
23 | 23 | #include "V8DealerFeature.h"
|
24 | 24 |
|
| 25 | +#include <regex> |
25 | 26 | #include <thread>
|
26 | 27 |
|
27 | 28 | #include "3rdParty/valgrind/valgrind.h"
|
|
41 | 42 | #include "Random/RandomGenerator.h"
|
42 | 43 | #include "RestServer/DatabaseFeature.h"
|
43 | 44 | #include "RestServer/DatabasePathFeature.h"
|
| 45 | +#include "Rest/Version.h" |
44 | 46 | #include "Scheduler/JobGuard.h"
|
45 | 47 | #include "Scheduler/SchedulerFeature.h"
|
46 | 48 | #include "Transaction/V8Context.h"
|
@@ -194,6 +196,27 @@ void V8DealerFeature::validateOptions(std::shared_ptr<ProgramOptions> options) {
|
194 | 196 | ctx->normalizePath(_startupDirectory, "javascript.startup-directory", true);
|
195 | 197 | ctx->normalizePath(_moduleDirectory, "javascript.module-directory", false);
|
196 | 198 |
|
| 199 | + // try to append the current version name to the startup directory, |
| 200 | + // so instead of "/path/to/js" we will get "/path/to/js/3.4.0" |
| 201 | + std::string const versionAppendix = std::regex_replace(rest::Version::getServerVersion(), std::regex("-.*$"), ""); |
| 202 | + std::string versionedPath = basics::FileUtils::buildFilename(_startupDirectory, versionAppendix); |
| 203 | + |
| 204 | + LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific startup-directory '" << versionedPath << "'"; |
| 205 | + if (basics::FileUtils::isDirectory(versionedPath)) { |
| 206 | + // version-specific js path exists! |
| 207 | + _startupDirectory = versionedPath; |
| 208 | + } |
| 209 | + |
| 210 | + for (auto& it : _moduleDirectory) { |
| 211 | + versionedPath = basics::FileUtils::buildFilename(it, versionAppendix); |
| 212 | + |
| 213 | + LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific module-directory '" << versionedPath << "'"; |
| 214 | + if (basics::FileUtils::isDirectory(versionedPath)) { |
| 215 | + // version-specific js path exists! |
| 216 | + it = versionedPath; |
| 217 | + } |
| 218 | + } |
| 219 | + |
197 | 220 | // check whether app-path was specified
|
198 | 221 | if (_appPath.empty()) {
|
199 | 222 | LOG_TOPIC(FATAL, arangodb::Logger::V8) << "no value has been specified for --javascript.app-path";
|
|
0 commit comments