From 88764f6252e2dffd60116e1ca18b3cf0df2d8fed Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Wed, 17 Jun 2015 15:53:31 +0200 Subject: [PATCH] Wait gracefully for the Coordinator to be fully bootstrapped until we give up on it. --- .../org/arangodb/cluster/kickstarter.js | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/js/server/modules/org/arangodb/cluster/kickstarter.js b/js/server/modules/org/arangodb/cluster/kickstarter.js index 28a2fb16b5..50411deeba 100644 --- a/js/server/modules/org/arangodb/cluster/kickstarter.js +++ b/js/server/modules/org/arangodb/cluster/kickstarter.js @@ -234,6 +234,12 @@ launchActions.startAgent = function (dispatchers, cmd, isRelaunch) { var clusterUrl = "http://" + clusterEndPoint; var agencyUrl = "http://" + extBind; + require("internal").print("snaotehusnoatehusaonuteh"); + if (require("internal").platform.substr(0,3) === 'win') { + require("internal").print("agentDataDir: " + agentDataDir); + agentDataDir = agentDataDir.split("\\").join("/"); + } + require("internal").print("agentDataDir: " + agentDataDir); var args = { "data-dir": agentDataDir, @@ -265,6 +271,9 @@ launchActions.startAgent = function (dispatchers, cmd, isRelaunch) { return {"error":true, "isStartAgent": true, "errorMessage": "agency binary not found at '" + agentPath + "'"}; } + + require("internal").print(JSON.stringify(toArgv(args))); + var pid = executeExternal(agentPath, toArgv(args)); var res; var count = 0; @@ -382,8 +391,6 @@ launchActions.startServers = function (dispatchers, cmd, isRelaunch) { } } var datadir = fs.join(dataPath,"data-"+cmd.agency.agencyPrefix+"-"+id); - args.push("--database.directory"); - args.push(datadir); if (!isRelaunch) { if (!fs.exists(dataPath)) { fs.makeDirectoryRecursive(dataPath); @@ -393,6 +400,8 @@ launchActions.startServers = function (dispatchers, cmd, isRelaunch) { } fs.makeDirectory(datadir); } + args.push("--database.directory"); + args.push(datadir); args = args.concat(dispatchers[cmd.dispatcher].arangodExtraArgs); var arangodPath = fs.makeAbsolute(cmd.arangodPath); if (arangodPath !== cmd.arangodPath) { @@ -468,17 +477,26 @@ launchActions.bootstrapServers = function (dispatchers, cmd, isRelaunch, }; // execute bootstrap command on first server + var retryCount = 0; + var result; var url = coordinators[0] + "/_admin/cluster/bootstrapDbServers"; var body = '{"isRelaunch": ' + (isRelaunch ? "true" : "false") + '}'; + while (retryCount < 10) { - var result = download(url, body, options); + result = download(url, body, options); - if (result.code !== 200) { - var err1 = "bootstrapping DB servers failed: " + extractErrorMessage(result); - console.error("%s", err1); - return {"error": true, "bootstrapServers": true, "errorMessage": err1}; + if ((result.code === 503) && (retryCount < 3)) { + wait(timeout); + retryCount+=1; + continue; + } + if (result.code !== 200) { + var err1 = "bootstrapping DB servers failed: " + extractErrorMessage(result); + console.error("%s", err1); + return {"error": true, "bootstrapServers": true, "errorMessage": err1}; + } + break; } - // execute cluster database upgrade url = coordinators[0] + "/_admin/cluster/upgradeClusterDatabase";