Skip to content
Snippets Groups Projects
Commit c7342575 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

(aws deploy) robustify 'destroy' command, handle some non-fatal provisioning errors more gracefully

parent 5feab202
No related branches found
No related tags found
No related merge requests found
......@@ -42,10 +42,10 @@ verbs['destroy'] = function(args) {
validateName(name);
process.stdout.write("trying to destroy VM for " + name + ".hacksign.in: ");
vm.destroy(name, function(cb, err) {
console.log(err ? "failed: " + err : "done");
vm.destroy(name, function(err) {
console.log(err ? ("failed: " + err) : "done");
process.stdout.write("trying to remove DNS for " + name + ".hacksign.in: ");
dns.deleteRecord(name, function(cb, err) {
dns.deleteRecord(name, function(err) {
console.log(err ? "failed: " + err : "done");
});
});
......@@ -84,7 +84,13 @@ verbs['deploy'] = function(args) {
checkErr(err);
console.log(" ... victory! server is accessible and configured");
git.addRemote(name, deets.ipAddress, function(err, r) {
checkErr(err);
if (err && /already exists/.test(err)) {
console.log("OOPS! you already have a git remote named 'test'!");
console.log("to create a new one: git remote add <name> " +
"app@" + deets.ipAddress + ":git");
} else {
checkErr(err);
}
console.log(" ... and your git remote is all set up");
console.log("");
printInstructions(name, deets);
......
......@@ -40,7 +40,6 @@ function doRequest(method, path, body, cb) {
};
exports.updateRecord = function (hostname, ip, cb) {
exports.deleteRecord(hostname, function() {} );
doRequest('GET', '/api/1.1/zones.xml', null, function(err, r) {
if (err) return cb(err);
var m = jsel.match('object:has(:root > .domain:val(?)) > .id .$t',
......@@ -60,6 +59,7 @@ exports.deleteRecord = function (hostname, cb) {
doRequest('GET', '/api/1.1/hosts.xml?fqdn=' + hostname + ".hacksign.in", null, function(err, r) {
if (err) return cb(err);
var m = jsel.match('.host .id > .$t', r);
if (!m.length) return cb("no such DNS record");
function deleteOne() {
if (!m.length) return cb(null);
var one = m.shift();
......@@ -80,4 +80,4 @@ exports.inUse = function (hostname, cb) {
if (m.length) return cb(null, m[0]);
cb(null, null);
});
}
\ No newline at end of file
}
......@@ -43,9 +43,8 @@ exports.destroy = function(name, cb) {
aws.call('TerminateInstances', {
InstanceId: r[name].instanceId
}, function(result) {
console.log(result);
try { return cb(result.Errors.Error.Message); } catch(e) {};
return null;
cb(null);
});
});
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment