Comparing version 0.1.5 to 0.1.6
{ | ||
//server authentication info | ||
"server": { | ||
"host": "hostname", | ||
"username": "root", | ||
"password": "password" | ||
//or pem file (ssh based authentication) | ||
//"pem": "~/.ssh/id_rsa" | ||
}, | ||
"servers": [ | ||
{ | ||
"host": "hostname", | ||
"username": "root", | ||
"password": "password" | ||
//or pem file (ssh based authentication) | ||
//"pem": "~/.ssh/id_rsa" | ||
} | ||
], | ||
@@ -11,0 +13,0 @@ //install MongoDB in the server |
@@ -14,22 +14,30 @@ var nodemiral = require('nodemiral'); | ||
this.config = config; | ||
// build the session | ||
this.sessions = this._createSession(config); | ||
} | ||
Actions.prototype._createSession = function(config) { | ||
var sessions = []; | ||
var options = { | ||
ssh: {'StrictHostKeyChecking': 'no', 'UserKnownHostsFile': '/dev/null'} | ||
}; | ||
var host = config.server.host; | ||
var auth = {username: config.server.username}; | ||
if(config.server.pem) { | ||
auth.pem = fs.readFileSync(path.resolve(config.server.pem), 'utf8'); | ||
} else { | ||
auth.password = config.server.password; | ||
} | ||
config.servers.forEach(function(server) { | ||
var host = server.host; | ||
var auth = {username: server.username}; | ||
if(server.pem) { | ||
auth.pem = fs.readFileSync(path.resolve(server.pem), 'utf8'); | ||
} else { | ||
auth.password = server.password; | ||
} | ||
this.session = nodemiral.session(host, auth, options); | ||
} | ||
sessions.push(nodemiral.session(host, auth, options)); | ||
}); | ||
return sessions; | ||
}; | ||
Actions.prototype.setup = function() { | ||
var taskList = taskLists.setup(this.config.setupMongo); | ||
taskList.run(this.session); | ||
taskList.run(this.sessions); | ||
}; | ||
@@ -54,3 +62,3 @@ | ||
var taskList = taskLists.deploy(bundlePath, self.cwd, self.config.env); | ||
taskList.run(self.session, afterCompleted); | ||
taskList.run(self.sessions, afterCompleted); | ||
} | ||
@@ -64,19 +72,26 @@ }); | ||
Actions.prototype.reconfig = function() { | ||
var env = this.config.env; | ||
var taskList = taskLists.reconfig(this.cwd, env); | ||
taskList.run(this.sessions); | ||
}; | ||
Actions.prototype.logs = function() { | ||
var tailOptions = process.argv.slice(3).join(" "); | ||
var command = 'sudo tail ' + tailOptions + ' /var/log/upstart/meteor.log'; | ||
var options = { | ||
onStdout: printOut, | ||
onStderr: printErr | ||
}; | ||
this.session.execute(command, options); | ||
this.sessions.forEach(function(session) { | ||
var hostPrefix = '[' + session._host + '] '; | ||
var options = { | ||
onStdout: function(data) { | ||
process.stdout.write(hostPrefix + data.toString()); | ||
}, | ||
onStderr: function(data) { | ||
process.stderr.write(hostPrefix + data.toString()); | ||
} | ||
}; | ||
function printErr(data) { | ||
process.stderr.write(data.toString()); | ||
} | ||
function printOut(data) { | ||
process.stdout.write(data.toString()); | ||
} | ||
session.execute(command, options); | ||
}); | ||
}; | ||
@@ -83,0 +98,0 @@ |
@@ -13,18 +13,25 @@ var cjson = require('cjson'); | ||
//validation | ||
if(!mupJson.server) { | ||
mupErrorLog('server information not exists'); | ||
} else if(!mupJson.server.host){ | ||
mupErrorLog('server host not exists'); | ||
} else if(!mupJson.server.username){ | ||
mupErrorLog('server username not exists'); | ||
} else if(!mupJson.server.password && !mupJson.server.pem){ | ||
mupErrorLog('server password or pem not exists'); | ||
} else if(!mupJson.app) { | ||
mupErrorLog('path to a app not exists'); | ||
} | ||
//validating servers | ||
if(!mupJson.servers || mupJson.servers.length == 0) { | ||
mupErrorLog('server information does not exists'); | ||
} else { | ||
mupJson.servers.forEach(function(server) { | ||
if(!server.host){ | ||
mupErrorLog('server host not exists'); | ||
} else if(!server.username){ | ||
mupErrorLog('server username not exists'); | ||
} else if(!server.password && !server.pem){ | ||
mupErrorLog('server password or pem not exists'); | ||
} else if(!mupJson.app) { | ||
mupErrorLog('path to a app not exists'); | ||
} | ||
//rewrite ~ with $HOME | ||
if(mupJson.server.pem) { | ||
mupJson.server.pem = mupJson.server.pem.replace('~', process.env.HOME); | ||
//rewrite ~ with $HOME | ||
if(server.pem) { | ||
server.pem = server.pem.replace('~', process.env.HOME); | ||
} else { | ||
//hint mup bin script to check whether sshpass installed or not | ||
mupJson._passwordExists = true; | ||
} | ||
}); | ||
} | ||
@@ -31,0 +38,0 @@ |
@@ -83,2 +83,33 @@ var nodemiral = require('nodemiral'); | ||
return taskList; | ||
}; | ||
exports.reconfig = function(cwd, env) { | ||
var taskList = nodemiral.taskList("Updating Configurations"); | ||
taskList.copy('setting up env vars', { | ||
src: path.resolve(TEMPLATES_DIR, 'env.sh'), | ||
dest: '/opt/meteor/config/env.sh', | ||
vars: { | ||
env: env || {} | ||
} | ||
}); | ||
var setttingsJsonPath = path.resolve(cwd, 'settings.json'); | ||
if(fs.existsSync(setttingsJsonPath)) { | ||
taskList.copy('uploading settings.json', { | ||
src: setttingsJsonPath, | ||
dest: '/opt/meteor/config/settings.json' | ||
}); | ||
} else { | ||
taskList.execute('cleaning up old settings.json', { | ||
command: 'sudo rm /opt/meteor/config/settings.json || :' | ||
}); | ||
} | ||
//deploying | ||
taskList.execute('calling deploy script', { | ||
command: 'sudo bash /opt/meteor/deploy.sh' | ||
}); | ||
return taskList; | ||
}; |
{ | ||
"name": "mup", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Production Quality Meteor Deplouments", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -62,2 +62,8 @@ # Meteor UP | ||
### Reconfiguring | ||
After you've edit configurations or settings.json, you can reconfigure the app without deploying again. Use following command for that. | ||
mup reconfig | ||
## Server Setup | ||
@@ -64,0 +70,0 @@ |
Sorry, the diff of this file is not supported yet
16876
269
79