diff --git a/Documentation/CMakeLists.txt b/Documentation/CMakeLists.txt index 8935aa5c4c..7b7f5e3b67 100644 --- a/Documentation/CMakeLists.txt +++ b/Documentation/CMakeLists.txt @@ -1,13 +1,14 @@ # -*- mode: CMAKE; -*- # swagger -add_custom_target (swagger - COMMAND ${PYTHON_EXECUTABLE} - ${PROJECT_SOURCE_DIR}/Documentation/Scripts/generateSwagger.py - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs api-docs - ${PROJECT_SOURCE_DIR}/Documentation/DocuBlocks/Rest/ - > ${PROJECT_SOURCE_DIR}/js/apps/system/_admin/aardvark/APP/api-docs.json) +add_custom_target(swagger + COMMAND ${PROJECT_SOURCE_DIR}/utils/generateSwagger.sh + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + +# swagger +add_custom_target(examples + COMMAND ${PROJECT_SOURCE_DIR}/utils/generateExamples.sh + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) # manual pages if (USE_MAINTAINER_MODE) diff --git a/arangosh/Shell/V8ShellFeature.cpp b/arangosh/Shell/V8ShellFeature.cpp index 8708eab5cf..901d99e9ea 100644 --- a/arangosh/Shell/V8ShellFeature.cpp +++ b/arangosh/Shell/V8ShellFeature.cpp @@ -138,8 +138,8 @@ void V8ShellFeature::stop() { v8::Locker locker{_isolate}; v8::Isolate::Scope isolate_scope{_isolate}; - TRI_v8_global_t* v8g = \ - static_cast(_isolate->GetData(V8DataSlot)); + TRI_v8_global_t* v8g = + static_cast(_isolate->GetData(V8DataSlot)); _isolate->SetData(V8DataSlot, nullptr); delete v8g; @@ -246,8 +246,7 @@ V8ClientConnection* V8ShellFeature::setup( v8connection = std::make_unique( connection, client->databaseName(), client->username(), client->password(), client->requestTimeout()); - } - else { + } else { client = nullptr; } } @@ -285,8 +284,10 @@ int V8ShellFeature::runShell(std::vector const& positionals) { V8LineEditor v8LineEditor(_isolate, context, "." + _name + ".history"); - v8LineEditor.setSignalFunction( - [&v8connection]() { v8connection->setInterrupted(true); }); + if (v8connection != nullptr) { + v8LineEditor.setSignalFunction( + [&v8connection]() { v8connection->setInterrupted(true); }); + } v8LineEditor.open(_console->autoComplete()); @@ -372,7 +373,9 @@ int V8ShellFeature::runShell(std::vector const& positionals) { promptError = true; } - v8connection->setInterrupted(false); + if (v8connection != nullptr) { + v8connection->setInterrupted(false); + } _console->stopPager(); _console->printLine(""); @@ -566,7 +569,7 @@ bool V8ShellFeature::jslint(std::vector const& files) { TRI_ExecuteJavaScriptString(_isolate, context, input, name, true); if (tryCatch.HasCaught()) { - LOG(ERR) << TRI_StringifyV8Exception(_isolate, &tryCatch); + LOG(ERR) << TRI_StringifyV8Exception(_isolate, &tryCatch); ok = false; } else { bool res = TRI_ObjectToBoolean(context->Global()->Get( @@ -855,8 +858,7 @@ void V8ShellFeature::initMode(ShellFeature::RunMode runMode, TRI_AddGlobalVariableVocbase( _isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_UNIT_TESTS"), - v8::Boolean::New(_isolate, - runMode == ShellFeature::RunMode::UNIT_TESTS)); + v8::Boolean::New(_isolate, runMode == ShellFeature::RunMode::UNIT_TESTS)); TRI_AddGlobalVariableVocbase( _isolate, context, TRI_V8_ASCII_STRING2(_isolate, "IS_JS_LINT"), diff --git a/js/common/bootstrap/modules.js b/js/common/bootstrap/modules.js index 61ee4aa3c4..9c49d1bf0c 100644 --- a/js/common/bootstrap/modules.js +++ b/js/common/bootstrap/modules.js @@ -375,19 +375,25 @@ Module._resolveDbModule = function (request) { if (request.charAt(0) !== '/') { request = '/' + request; } + var dbModule = Module._dbCache[request]; - if (!dbModule && internal.db._modules !== undefined) { + + if (!dbModule && internal.db !== undefined && internal.db._modules !== undefined) { dbModule = internal.db._modules.firstExample({path: request}); + if (!dbModule) { // try again, but prefix module with '/db' as some modules seem // to have been saved with that prefix... dbModule = internal.db._modules.firstExample({path: '/db:' + request}); + if (!dbModule) { return null; } } + Module._dbCache[request] = dbModule; } + return dbModule; }; diff --git a/scripts/startLocalCluster.sh b/scripts/startLocalCluster.sh index acea2ae613..8fe35fb272 100755 --- a/scripts/startLocalCluster.sh +++ b/scripts/startLocalCluster.sh @@ -25,6 +25,8 @@ if [ ! -z "$3" ] ; then fi fi +SECONDARIES="$4" + if [ -z "$XTERMOPTIONS" ] ; then XTERMOPTIONS="-fa Monospace-14 -bg white -fg black -geometry 80x43" fi @@ -57,7 +59,6 @@ start() { --log.requests-file cluster/$PORT.req \ --server.disable-statistics true \ --server.foxx-queues false \ - --server.foxx-queues false \ --javascript.startup-directory ./js \ --server.disable-authentication true \ --javascript.app-path ./js/apps \ @@ -163,6 +164,35 @@ for p in `seq 8530 $PORTTOPCO` ; do testServer $p done +if [ -n "$SECONDARIES" ]; then + let index=1 + PORTTOPSE=`expr 8729 + $NRDBSERVERS - 1` + for PORT in `seq 8729 $PORTTOPSE` ; do + mkdir cluster/data$PORT + + CLUSTER_ID="Secondary$index" + + echo Registering secondary $CLUSTER_ID for "DBServer$index" + curl -f -X PUT --data "{\"primary\": \"DBServer$index\", \"oldSecondary\": \"none\", \"newSecondary\": \"$CLUSTER_ID\"}" -H "Content-Type: application/json" localhost:8530/_admin/cluster/replaceSecondary + echo Starting Secondary $CLUSTER_ID on port $PORT + build/bin/arangod --database.directory cluster/data$PORT \ + --cluster.agency-endpoint tcp://127.0.0.1:4001 \ + --cluster.my-address tcp://127.0.0.1:$PORT \ + --server.endpoint tcp://127.0.0.1:$PORT \ + --cluster.my-id $CLUSTER_ID \ + --log.file cluster/$PORT.log \ + --log.requests-file cluster/$PORT.req \ + --server.disable-statistics true \ + --server.foxx-queues false \ + --javascript.startup-directory ./js \ + --server.disable-authentication true \ + --javascript.app-path ./js/apps \ + > cluster/$PORT.stdout 2>&1 & + + let index=$index+1 + done +fi + echo Bootstrapping DBServers... curl -s -X POST "http://127.0.0.1:8530/_admin/cluster/bootstrapDbServers" \ -d '{"isRelaunch":false}' >> cluster/DBServersUpgrade.log 2>&1 diff --git a/utils/generateErrorfile.py b/utils/generateErrorfile.py old mode 100755 new mode 100644 diff --git a/utils/generateExamples b/utils/generateExamples deleted file mode 100755 index fe0aa414b1..0000000000 --- a/utils/generateExamples +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -export PID=$$ - -if test -n "$ORIGINAL_PATH"; then - # running in cygwin... - PS='\' - export EXT=".exe" -else - export EXT="" - PS='/' -fi; - -SCRIPT="utils${PS}generateExamples.js" -LOGFILE="out${PS}log-$PID" -DBDIR="out${PS}data-$PID" - -mkdir -p ${DBDIR} - -echo Database has its data in ${DBDIR} -echo Logfile is in ${LOGFILE} - -if [ -z "${ARANGOD}" ]; then - if [ -x build/bin/arangod ]; then - ARANGOD=build/bin/arangod - elif [ -x bin/arangosh ]; then - ARANGOD=bin/arangod - else - echo "$0: cannot locate arangod" - fi -fi - -${ARANGOD} \ - --configuration none \ - --cluster.agent-path bin${PS}etcd-arango${EXT} \ - --cluster.arangod-path bin${PS}arangod \ - --cluster.coordinator-config etc${PS}relative${PS}arangod-coordinator.conf \ - --cluster.dbserver-config etc${PS}relative${PS}arangod-dbserver.conf \ - --cluster.disable-dispatcher-frontend false \ - --cluster.disable-dispatcher-kickstarter false \ - --cluster.data-path cluster \ - --cluster.log-path cluster \ - --database.directory ${DBDIR} \ - --log.file ${LOGFILE} \ - --server.endpoint tcp://127.0.0.1:$PORT \ - --javascript.startup-directory js \ - --javascript.app-path js${PS}apps \ - --javascript.script $SCRIPT \ - --no-server \ - --temp-path ${PS}var${PS}tmp \ - "${ARGS[@]}" \ - -if test $? -eq 0; then - echo "removing ${LOGFILE} ${DBDIR}" - rm -rf ${LOGFILE} ${DBDIR} -else - echo "failed - don't remove ${LOGFILE} ${DBDIR} - here's the logfile:" - cat ${LOGFILE} -fi - -echo Server has terminated. diff --git a/utils/generateExamples.js b/utils/generateExamples.js index 2531d75833..7ee130d5c4 100644 --- a/utils/generateExamples.js +++ b/utils/generateExamples.js @@ -1,58 +1,93 @@ /*jshint globalstrict:false, unused:false */ /*global start_pretty_print */ +'use strict'; -var fs = require("fs"); -var internal = require("internal"); -var executeExternal = require("internal").executeExternal; -var executeExternalAndWait = internal.executeExternalAndWait; -var download = require("internal").download; -var print = internal.print; -var wait = require("internal").wait; -var killExternal = require("internal").killExternal; -var toArgv = require("internal").toArgv; -var statusExternal = require("internal").statusExternal; +const fs = require("fs"); +const internal = require("internal"); +const executeExternal = internal.executeExternal; +const executeExternalAndWait = internal.executeExternalAndWait; +const download = internal.download; +const print = internal.print; +const wait = internal.wait; +const killExternal = internal.killExternal; +const toArgv = internal.toArgv; +const statusExternal = internal.statusExternal; +const testPort = internal.testPort; -var yaml = require("js-yaml"); -var endpointToURL = require("@arangodb/cluster/planner").endpointToURL; -var PortFinder = require("@arangodb/cluster").PortFinder; +const yaml = require("js-yaml"); -var documentationSourceDirs = [ +const documentationSourceDirs = [ fs.join(fs.makeAbsolute(''), "Documentation/Examples/setup-arangosh.js"), - fs.join(fs.makeAbsolute(''), "Documentation/Books/Users"), - fs.join(fs.makeAbsolute(''), "js/actions"), - fs.join(fs.makeAbsolute(''), "js/client"), - fs.join(fs.makeAbsolute(''), "js/common"), - fs.join(fs.makeAbsolute(''), "js/server"), - fs.join(fs.makeAbsolute(''), "js/apps/system/_api/gharial/APP")]; + fs.join(fs.makeAbsolute(''), "Documentation/DocuBlocks"), + fs.join(fs.makeAbsolute(''), "Documentation/Books/Users") +]; -var theScript = 'Documentation/Scripts/generateExamples.py'; +const theScript = 'utils/generateExamples.py'; -var scriptArguments = { +const scriptArguments = { 'outputDir': fs.join(fs.makeAbsolute(''), "Documentation/Examples"), - 'outputFile': '/tmp/arangosh.examples.js' + 'outputFile': fs.join(fs.makeAbsolute(''), "arangosh.examples.js") }; -function main (argv) { - "use strict"; - var thePython = 'python'; - var test = argv[1]; - var options = {}; - var serverEndpoint = ''; - var startServer = true; - var instanceInfo = {}; - var serverCrashed = false; - var protocol = 'tcp'; - var tmpDataDir = fs.getTempFile(); - var count = 0; +let ARANGOD; +let ARANGOSH; + +if (fs.exists("bin")) { + ARANGOD = fs.join(fs.join(fs.makeAbsolute('')), "bin/arangod"); + ARANGOSH = fs.join(fs.join(fs.makeAbsolute('')), "bin/arangosh"); +} +else { + ARANGOD = fs.join(fs.join(fs.makeAbsolute('')), "build/bin/arangod"); + ARANGOSH = fs.join(fs.join(fs.makeAbsolute('')), "build/bin/arangosh"); +} + +function endpointToURL(endpoint) { + if (endpoint.substr(0, 6) === "ssl://") { + return "https://" + endpoint.substr(6); + } + + const pos = endpoint.indexOf("://"); + + if (pos === -1) { + return "http://" + endpoint; + } + + return "http" + endpoint.substr(pos); +} + +function findFreePort() { + while (true) { + const port = Math.floor(Math.random() * (65536 - 1024)) + 1024; + const free = testPort("tcp://0.0.0.0:" + port); + + if (free) { + return port; + } + } + + return 8529; +} + +function main(argv) { + let thePython = 'python'; + let options = {}; + let serverEndpoint = ''; + let startServer = true; + let instanceInfo = {}; + let serverCrashed = false; + let protocol = 'tcp'; + let tmpDataDir = fs.getTempFile(); + let count = 0; try { - options = internal.parseArgv(argv, 1); - } - catch (x) { + options = internal.parseArgv(argv, 0); + } catch (x) { print("failed to parse the options: " + x.message); return -1; } + print(options); + if (options.hasOwnProperty('withPython')) { thePython = options.withPython; } @@ -65,13 +100,13 @@ function main (argv) { startServer = false; serverEndpoint = options['server.endpoint']; } - var args = [theScript].concat(internal.toArgv(scriptArguments)); + + let args = [theScript].concat(internal.toArgv(scriptArguments)); args = args.concat(['--arangoshSetup']); args = args.concat(documentationSourceDirs); - // internal.print(JSON.stringify(args)); + let res = executeExternalAndWait(thePython, args); - var res = executeExternalAndWait(thePython, args); if (res.exit !== 0) { print("parsing the examples failed - aborting!"); print(res); @@ -79,36 +114,46 @@ function main (argv) { } if (startServer) { - // We use the PortFinder to find a free port for our subinstance, - // to this end, we have to fake a dummy dispatcher: - var dispatcher = {endpoint: "tcp://127.0.0.1:", avoidPorts: {}, id: "me"}; - var pf = new PortFinder([8529],dispatcher); - var port = pf.next(); + let port = findFreePort(); instanceInfo.port = port; - serverEndpoint = protocol+"://127.0.0.1:"+port; - + serverEndpoint = protocol + "://127.0.0.1:" + port; + instanceInfo.url = endpointToURL(serverEndpoint); - var serverArgs = {}; + fs.makeDirectoryRecursive(fs.join(tmpDataDir, "data")); + + let serverArgs = {}; + + serverArgs["configuration"] = "none"; + serverArgs["database.directory"] = fs.join(tmpDataDir, "data"); + serverArgs["javascript.app-path"] = fs.join(tmpDataDir, "apps"); + serverArgs["javascript.startup-directory"] = "js"; + serverArgs["log.file"] = fs.join(tmpDataDir, "log"); + serverArgs["server.disable-authentication"] = "true"; serverArgs["server.endpoint"] = serverEndpoint; - serverArgs["database.directory"] = fs.join(tmpDataDir,"data"); - fs.makeDirectoryRecursive(fs.join(tmpDataDir,"data")); - args["log.file"] = fs.join(tmpDataDir,"log"); - instanceInfo.pid = executeExternal(fs.join("bin","arangod"), toArgv(serverArgs)); + serverArgs["server.threads"] = "3"; + + print("================================================================================"); + print(toArgv(serverArgs)); + instanceInfo.pid = executeExternal(ARANGOD, toArgv(serverArgs)); + // Wait until the server is up: count = 0; instanceInfo.endpoint = serverEndpoint; while (true) { wait(0.5, false); - var r = download(instanceInfo.url + "/_api/version", ""); + let r = download(instanceInfo.url + "/_api/version", ""); - if (! r.error && r.code === 200) { + if (!r.error && r.code === 200) { break; } - count ++; + + count++; + if (count % 60 === 0) { res = statusExternal(instanceInfo.pid, false); + if (res.status !== "RUNNING") { print("start failed - process is gone: " + yaml.safeDump(res)); return 1; @@ -116,67 +161,71 @@ function main (argv) { } } } - var arangoshArgs = { + + let arangoshArgs = { 'configuration': fs.join(fs.makeAbsolute(''), 'etc', 'relative', 'arangosh.conf'), 'server.password': "", 'server.endpoint': serverEndpoint, 'javascript.execute': scriptArguments.outputFile }; - res = executeExternalAndWait('bin/arangosh', internal.toArgv(arangoshArgs)); + res = executeExternalAndWait(ARANGOSH, internal.toArgv(arangoshArgs)); if (startServer) { if (typeof(instanceInfo.exitStatus) === 'undefined') { - download(instanceInfo.url+"/_admin/shutdown",""); + download(instanceInfo.url + "/_admin/shutdown", ""); print("Waiting for server shut down"); count = 0; - var bar = "["; + let bar = "["; + while (1) { instanceInfo.exitStatus = statusExternal(instanceInfo.pid, false); + if (instanceInfo.exitStatus.status === "RUNNING") { - count ++; + count++; if (typeof(options.valgrind) === 'string') { wait(1); continue; } - if (count % 10 ===0) { + if (count % 10 === 0) { bar = bar + "#"; } if (count > 600) { print("forcefully terminating " + yaml.safeDump(instanceInfo.pid) + - " after 600 s grace period; marking crashy."); + " after 600 s grace period; marking crashy."); serverCrashed = true; killExternal(instanceInfo.pid); break; - } - else { + } else { wait(1); } - } - else if (instanceInfo.exitStatus.status !== "TERMINATED") { + } else if (instanceInfo.exitStatus.status !== "TERMINATED") { if (instanceInfo.exitStatus.hasOwnProperty('signal')) { print("Server shut down with : " + - yaml.safeDump(instanceInfo.exitStatus) + - " marking build as crashy."); + yaml.safeDump(instanceInfo.exitStatus) + + " marking build as crashy."); serverCrashed = true; break; } - if (require("internal").platform.substr(0,3) === 'win') { + if (internal.platform.substr(0, 3) === 'win') { // Windows: wait for procdump to do its job... statusExternal(instanceInfo.monitor, true); } - } - else { + } else { print("Server shutdown: Success."); break; // Success. } } + if (count > 10) { print("long Server shutdown: " + bar + ']'); } } } + return 0; } + +main(ARGUMENTS); diff --git a/Documentation/Scripts/generateExamples.py b/utils/generateExamples.py similarity index 99% rename from Documentation/Scripts/generateExamples.py rename to utils/generateExamples.py index b0a7ce157e..3f617ae0c3 100644 --- a/Documentation/Scripts/generateExamples.py +++ b/utils/generateExamples.py @@ -1,8 +1,4 @@ ################################################################################ -### @brief creates examples from documentation files -### -### @file -### ### DISCLAIMER ### ### Copyright by triAGENS GmbH - All rights reserved. @@ -128,14 +124,13 @@ OPTION_OUTPUT_DIR = 2 OPTION_FILTER = 3 OPTION_OUTPUT_FILE = 4 -fstate = OPTION_NORMAL - escapeBS = re.compile("\\\\") doubleBS = "\\\\\\\\" ################################################################################ ### @brief generate arangosh example headers with functions etc. needed later ################################################################################ + def generateArangoshHeader(): headerF = open("./Documentation/Scripts/exampleHeader.js", "r") print headerF.read() @@ -144,6 +139,7 @@ def generateArangoshHeader(): ################################################################################ ### @brief Try to match the start of a command section ################################################################################ + regularStartLine = re.compile(r'^(/// )? *@EXAMPLE_ARANGOSH_OUTPUT{([^}]*)}') runLine = re.compile(r'^(/// )? *@EXAMPLE_ARANGOSH_RUN{([^}]*)}') @@ -160,6 +156,7 @@ def matchStartLine(line, filename): if name in ArangoshFiles: print >> sys.stderr, "%s\nduplicate test name '%s' in file %s!\n%s\n" % ('#' * 80, name, filename, '#' * 80) sys.exit(1) + # if we match for filters, only output these! if ((FilterForTestcase != None) and not FilterForTestcase.match(name)): filterTestList.append(name) @@ -184,6 +181,7 @@ def matchStartLine(line, filename): ArangoshFiles[name] = True return (name, STATE_ARANGOSH_RUN) + # Not found, remain in STATE_BEGIN return ("", STATE_BEGIN) @@ -194,9 +192,11 @@ TESTLINES="testlines" TYPE="type" LINE_NO="lineNo" STRING="string" + ################################################################################ ### @brief loop over the lines of one input file ################################################################################ + def analyzeFile(f, filename): global RunTests, TESTLINES, TYPE, LINE_NO, STRING strip = None @@ -294,7 +294,6 @@ def generateSetupFunction(): print "(function () {\n%s}());" % ArangoshSetup print - ################################################################################ ### @brief generate arangosh example ################################################################################ @@ -302,6 +301,7 @@ def generateSetupFunction(): loopDetectRE = re.compile(r'^[ \n]*(while|if|var|throw|for) ') expectErrorRE = re.compile(r'.*// *xpError\((.*)\).*') #expectErrorRE = re.compile(r'.*//\s*xpError\(([^)]*)\)/') + def generateArangoshOutput(testName): value = RunTests[testName] #print value @@ -370,7 +370,6 @@ def generateArangoshOutput(testName): }()); ''' - ################################################################################ ### @brief generate arangosh run ################################################################################ @@ -429,6 +428,7 @@ def generateArangoshRun(testName): ################################################################################ ### @brief generate arangosh run ################################################################################ + def generateArangoshShutdown(): print ''' if (allErrors.length > 0) { @@ -437,29 +437,35 @@ if (allErrors.length > 0) { } ''' - ################################################################################ ### @brief get file names ################################################################################ + def loopDirectories(): global ArangoshSetup, OutputDir, FilterForTestcase + argv = sys.argv argv.pop(0) filenames = [] + fstate = OPTION_NORMAL for filename in argv: if filename == "--arangoshSetup": fstate = OPTION_ARANGOSH_SETUP continue + if filename == "--onlyThisOne": fstate = OPTION_FILTER continue + if filename == "--outputDir": fstate = OPTION_OUTPUT_DIR continue + if filename == "--outputFile": fstate = OPTION_OUTPUT_FILE continue + if fstate == OPTION_NORMAL: if os.path.isdir(filename): for root, dirs, files in os.walk(filename): @@ -468,11 +474,12 @@ def loopDirectories(): filenames.append(os.path.join(root, file)) else: filenames.append(filename) + elif fstate == OPTION_FILTER: fstate = OPTION_NORMAL if (len(filename) > 0): FilterForTestcase = re.compile(filename); - + elif fstate == OPTION_ARANGOSH_SETUP: fstate = OPTION_NORMAL f = open(filename, "r") @@ -486,11 +493,11 @@ def loopDirectories(): elif fstate == OPTION_OUTPUT_DIR: fstate = OPTION_NORMAL OutputDir = filename + elif fstate == OPTION_OUTPUT_FILE: fstate = OPTION_NORMAL sys.stdout = open(filename, 'w') - print >> sys.stderr, repr(filenames) for filename in filenames: if (filename.find("#") < 0): f = open(filename, "r") @@ -512,10 +519,10 @@ def generateTestCases(): elif RunTests[thisTest][TYPE] == STATE_ARANGOSH_RUN: generateArangoshRun(thisTest) - ################################################################################ ### @brief main ################################################################################ + loopDirectories() print >> sys.stderr, "filtering test cases %s" %(filterTestList) diff --git a/utils/generateExamples.sh b/utils/generateExamples.sh new file mode 100755 index 0000000000..02bf3715cc --- /dev/null +++ b/utils/generateExamples.sh @@ -0,0 +1,49 @@ +#!/bin/bash +export PID=$$ + +if test -n "$ORIGINAL_PATH"; then + # running in cygwin... + PS='\' + export EXT=".exe" +else + export EXT="" + PS='/' +fi; + +SCRIPT="utils${PS}generateExamples.js" +LOGFILE="out${PS}log-$PID" +DBDIR="out${PS}data-$PID" + +mkdir -p ${DBDIR} + +echo Database has its data in ${DBDIR} +echo Logfile is in ${LOGFILE} + +if [ -z "${ARANGOSH}" ]; then + if [ -x build/bin/arangosh ]; then + ARANGOSH=build/bin/arangosh + elif [ -x bin/arangosh ]; then + ARANGOSH=bin/arangosh + else + echo "$0: cannot locate arangosh" + fi +fi + +${ARANGOSH} \ + --configuration none \ + --server.endpoint none \ + --log.file ${LOGFILE} \ + --javascript.startup-directory js \ + --javascript.execute $SCRIPT \ + --server.password "" \ + "${ARGS[@]}" + +if test $? -eq 0; then + echo "removing ${LOGFILE} ${DBDIR}" + rm -rf ${LOGFILE} ${DBDIR} arangosh.examples.js +else + echo "failed - don't remove ${LOGFILE} ${DBDIR} - here's the logfile:" + cat ${LOGFILE} +fi + +echo Server has terminated. diff --git a/utils/generateMimetypes.py b/utils/generateMimetypes.py old mode 100755 new mode 100644 diff --git a/Documentation/Scripts/generateSwagger.py b/utils/generateSwagger.py similarity index 99% rename from Documentation/Scripts/generateSwagger.py rename to utils/generateSwagger.py index 82636b6fa0..6ff227c634 100755 --- a/Documentation/Scripts/generateSwagger.py +++ b/utils/generateSwagger.py @@ -1010,7 +1010,7 @@ def example_arangosh_run(cargo, r=Regexen()): exampleHeader = brTrim(operation['x-examples'][currentExample]).strip() # new examples code TODO should include for each example own object in json file - examplefile = open(os.path.join(os.path.dirname(__file__), '../Examples/' + parameters(last) + '.generated')) + examplefile = open(os.path.join(os.path.dirname(__file__), '../Documentation/Examples/' + parameters(last) + '.generated')) operation['x-examples'][currentExample]= '
Example: ' + exampleHeader.strip('\n ') + '

'
 
     for line in examplefile.readlines():
diff --git a/utils/generateSwagger.sh b/utils/generateSwagger.sh
new file mode 100755
index 0000000000..0d3e3365f9
--- /dev/null
+++ b/utils/generateSwagger.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+python \
+  `pwd`/utils/generateSwagger.py \
+  `pwd` \
+  `pwd`/js/apps/system/_admin/aardvark/APP/api-docs \
+  api-docs \
+  `pwd`/Documentation/DocuBlocks/Rest \
+  > `pwd`/js/apps/system/_admin/aardvark/APP/api-docs.json