mirror of https://gitee.com/bigwinds/arangodb
Improved upgrade procedure, it now runs smoothly, at least once
This commit is contained in:
parent
1f2f33cf17
commit
aa72dacefd
|
@ -41,12 +41,11 @@ var ArangoError = arangodb.ArangoError;
|
||||||
var mountRegEx = /^(\/[a-zA-Z0-9_\-%]+)+$/;
|
var mountRegEx = /^(\/[a-zA-Z0-9_\-%]+)+$/;
|
||||||
var mountAppRegEx = /\/APP(\/|$)/i;
|
var mountAppRegEx = /\/APP(\/|$)/i;
|
||||||
|
|
||||||
// TODO Only temporary
|
var getStorage = function() {
|
||||||
var tmp_getStorage = function() {
|
|
||||||
"use strict";
|
"use strict";
|
||||||
var c = db._tmp_aal;
|
var c = db._apps;
|
||||||
if (c === undefined) {
|
if (c === undefined) {
|
||||||
c = db._create("_tmp_aal", {isSystem: true});
|
c = db._create("_apps", {isSystem: true});
|
||||||
c.ensureUniqueConstraint("mount");
|
c.ensureUniqueConstraint("mount");
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
|
@ -282,7 +281,7 @@ function getStorage () {
|
||||||
function listJson (showPrefix, onlyDevelopment) {
|
function listJson (showPrefix, onlyDevelopment) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var mounts = tmp_getStorage();
|
var mounts = getStorage();
|
||||||
var cursor;
|
var cursor;
|
||||||
if (onlyDevelopment) {
|
if (onlyDevelopment) {
|
||||||
cursor = mounts.byExample({isDevelopment: true});
|
cursor = mounts.byExample({isDevelopment: true});
|
||||||
|
@ -406,7 +405,7 @@ function validateAppName (name) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
function mountedApp (mount) {
|
function mountedApp (mount) {
|
||||||
"use strict";
|
"use strict";
|
||||||
return tmp_getStorage().firstExample({mount: mount});
|
return getStorage().firstExample({mount: mount});
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -414,7 +413,7 @@ function mountedApp (mount) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
function updateApp (mount, update) {
|
function updateApp (mount, update) {
|
||||||
"use strict";
|
"use strict";
|
||||||
return tmp_getStorage().updateByExample({mount: mount}, update);
|
return getStorage().updateByExample({mount: mount}, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -475,8 +474,7 @@ exports.validateAppName = validateAppName;
|
||||||
exports.validateMount = validateMount;
|
exports.validateMount = validateMount;
|
||||||
exports.typeToRegex = typeToRegex;
|
exports.typeToRegex = typeToRegex;
|
||||||
exports.zipDirectory = zipDirectory;
|
exports.zipDirectory = zipDirectory;
|
||||||
|
exports.getStorage = getStorage;
|
||||||
exports.tmp_getStorage = tmp_getStorage;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
var refillCaches = function() {
|
var refillCaches = function() {
|
||||||
appCache = {};
|
appCache = {};
|
||||||
|
|
||||||
var cursor = utils.tmp_getStorage().all();
|
var cursor = utils.getStorage().all();
|
||||||
var config, app;
|
var config, app;
|
||||||
var routes = [];
|
var routes = [];
|
||||||
|
|
||||||
|
@ -467,12 +467,15 @@
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// throw away temporary app folder
|
// throw away temporary app folder
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
if (found !== mf) {
|
||||||
try {
|
try {
|
||||||
|
require("console").log(tempFile);
|
||||||
fs.removeDirectoryRecursive(tempFile);
|
fs.removeDirectoryRecursive(tempFile);
|
||||||
}
|
}
|
||||||
catch (err1) {
|
catch (err1) {
|
||||||
arangodb.printf("Cannot remove temporary folder '%s'\n Stack: %s", tempFile, err1.stack || String(err1));
|
arangodb.printf("Cannot remove temporary folder '%s'\n Stack: %s", tempFile, err1.stack || String(err1));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -596,7 +599,7 @@
|
||||||
var _scanFoxx = function(mount, options, activateDevelopment) {
|
var _scanFoxx = function(mount, options, activateDevelopment) {
|
||||||
delete appCache[mount];
|
delete appCache[mount];
|
||||||
var app = createApp(mount, options, activateDevelopment);
|
var app = createApp(mount, options, activateDevelopment);
|
||||||
utils.tmp_getStorage().save(app.toJSON());
|
utils.getStorage().save(app.toJSON());
|
||||||
return app;
|
return app;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -629,7 +632,7 @@
|
||||||
[ mount ] );
|
[ mount ] );
|
||||||
|
|
||||||
var old = lookupApp(mount);
|
var old = lookupApp(mount);
|
||||||
var collection = utils.tmp_getStorage();
|
var collection = utils.getStorage();
|
||||||
db._executeTransaction({
|
db._executeTransaction({
|
||||||
collections: {
|
collections: {
|
||||||
write: collection.name()
|
write: collection.name()
|
||||||
|
@ -650,7 +653,7 @@
|
||||||
var _install = function(appInfo, mount, options, runSetup) {
|
var _install = function(appInfo, mount, options, runSetup) {
|
||||||
var targetPath = computeAppPath(mount, true);
|
var targetPath = computeAppPath(mount, true);
|
||||||
var app;
|
var app;
|
||||||
var collection = utils.tmp_getStorage();
|
var collection = utils.getStorage();
|
||||||
if (fs.exists(targetPath)) {
|
if (fs.exists(targetPath)) {
|
||||||
throw new Error("An app is already installed at this location.");
|
throw new Error("An app is already installed at this location.");
|
||||||
}
|
}
|
||||||
|
@ -710,7 +713,7 @@
|
||||||
|
|
||||||
var _uninstall = function(mount) {
|
var _uninstall = function(mount) {
|
||||||
var app = lookupApp(mount);
|
var app = lookupApp(mount);
|
||||||
var collection = utils.tmp_getStorage();
|
var collection = utils.getStorage();
|
||||||
var targetPath = computeAppPath(mount, true);
|
var targetPath = computeAppPath(mount, true);
|
||||||
if (!fs.exists(targetPath)) {
|
if (!fs.exists(targetPath)) {
|
||||||
throw "No foxx app found at this location.";
|
throw "No foxx app found at this location.";
|
||||||
|
|
|
@ -1416,31 +1416,6 @@ function updateGlobals() {
|
||||||
// --SECTION-- upgrade 2.4 - 2.5
|
// --SECTION-- upgrade 2.4 - 2.5
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief create new application collection
|
|
||||||
///
|
|
||||||
/// Setup the collection _apps
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
addTask({
|
|
||||||
name: "setupApps",
|
|
||||||
description: "setup _apps collection",
|
|
||||||
|
|
||||||
mode: [ MODE_PRODUCTION, MODE_DEVELOPMENT ],
|
|
||||||
cluster: [ CLUSTER_NONE, CLUSTER_COORDINATOR_GLOBAL ],
|
|
||||||
database: [ DATABASE_INIT, DATABASE_UPGRADE ],
|
|
||||||
|
|
||||||
task: function () {
|
|
||||||
var created = createSystemCollection("_apps");
|
|
||||||
if (!created) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var apps = getCollection("_apps");
|
|
||||||
apps.ensureUniqueConstraint("mount");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief move applications
|
/// @brief move applications
|
||||||
///
|
///
|
||||||
|
@ -1474,7 +1449,12 @@ function updateGlobals() {
|
||||||
while (appsToZip.hasNext()) {
|
while (appsToZip.hasNext()) {
|
||||||
tmp = appsToZip.next();
|
tmp = appsToZip.next();
|
||||||
path = fs.join(module.oldAppPath(), tmp.path);
|
path = fs.join(module.oldAppPath(), tmp.path);
|
||||||
|
try {
|
||||||
mapAppZip[tmp.app] = fmUtils.zipDirectory(path);
|
mapAppZip[tmp.app] = fmUtils.zipDirectory(path);
|
||||||
|
} catch (e) {
|
||||||
|
logger.errorLines("Tried to move app " + tmp.app + " but it was not found at app-path" + path +
|
||||||
|
" : " +(e.stack || String(e)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. If development mode, Zip all development APPs and create a map name => zipFile
|
// 2. If development mode, Zip all development APPs and create a map name => zipFile
|
||||||
|
@ -1486,8 +1466,13 @@ function updateGlobals() {
|
||||||
appsToZip = fs.list(devPath);
|
appsToZip = fs.list(devPath);
|
||||||
for (i = 0; i < appsToZip.length; ++i) {
|
for (i = 0; i < appsToZip.length; ++i) {
|
||||||
path = fs.join(devPath, appsToZip[i]);
|
path = fs.join(devPath, appsToZip[i]);
|
||||||
if (fs.exists() && fs.isDirectory(path)) {
|
if (fs.exists(path) && fs.isDirectory(path)) {
|
||||||
|
try {
|
||||||
mapDevAppZip[appsToZip[i]] = fmUtils.zipDirectory(path);
|
mapDevAppZip[appsToZip[i]] = fmUtils.zipDirectory(path);
|
||||||
|
} catch (e) {
|
||||||
|
logger.errorLines("Tried to move app " + appsToZip[i] + " but it was not found at app-path" + path +
|
||||||
|
" : " + (e.stack || String(e)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1503,6 +1488,7 @@ function updateGlobals() {
|
||||||
tmp = appsToInstall.next();
|
tmp = appsToInstall.next();
|
||||||
if (mapAppZip.hasOwnProperty(tmp.app)) {
|
if (mapAppZip.hasOwnProperty(tmp.app)) {
|
||||||
foxxManager.install(mapAppZip[tmp.app], tmp.mount, {}, false);
|
foxxManager.install(mapAppZip[tmp.app], tmp.mount, {}, false);
|
||||||
|
logger.log("Upgraded app '" + tmp.app + "' on mount: " + tmp.mount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1514,10 +1500,12 @@ function updateGlobals() {
|
||||||
name = appsToInstall[i];
|
name = appsToInstall[i];
|
||||||
foxxManager.install(mapDevAppZip[name], "/dev/" + name, {}, false);
|
foxxManager.install(mapDevAppZip[name], "/dev/" + name, {}, false);
|
||||||
foxxManager.development("/dev/" + name);
|
foxxManager.development("/dev/" + name);
|
||||||
|
logger.log("Upgraded dev app '" + name + "' on mount: /dev/" + name);
|
||||||
try {
|
try {
|
||||||
fs.remove(mapDevAppZip[name]);
|
fs.remove(mapDevAppZip[name]);
|
||||||
} catch (err1) {
|
} catch (err1) {
|
||||||
require("org/arangodb").printf("Cannot remove temporary file '%s'\n", mapDevAppZip[name]);
|
logger.errorLines("Could not remove temporary file '%s'\n%s",
|
||||||
|
mapDevAppZip[name], err1.stack || String(err1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,12 +1515,12 @@ function updateGlobals() {
|
||||||
try {
|
try {
|
||||||
fs.remove(mapAppZip[appsToInstall[i]]);
|
fs.remove(mapAppZip[appsToInstall[i]]);
|
||||||
} catch (err1) {
|
} catch (err1) {
|
||||||
require("org/arangodb").printf("Cannot remove temporary file '%s'\n", mapAppZip[appsToInstall[i]]);
|
logger.errorLines("Could not remove temporary file '%s'\n%s",
|
||||||
|
mapDevAppZip[name], err1.stack || String(err1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1549,7 +1537,8 @@ function updateGlobals() {
|
||||||
if (!aal) {
|
if (!aal) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return aal.drop();
|
aal.drop();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue