boom-deploy
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -24,8 +24,8 @@ var path = require('path'); | ||
boom.list(); | ||
} else if (argv._.length == 2) { | ||
} else if (argv._.length >= 2) { | ||
var env = argv._[0]; | ||
var task = argv._[1]; | ||
boom.go(env, task); | ||
boom.go(env, task, argv._.slice(2)); | ||
} else { | ||
optimist.showHelp(); | ||
} |
new Task('deploy', function(){ | ||
deploy(); | ||
new Task('deploy', function(isForce){ | ||
deploy(isForce); | ||
myDeploy(); | ||
removeOldReleases(); | ||
}, 'deploy app'); | ||
@@ -9,7 +10,13 @@ | ||
new Task('deploy:force', function(){ | ||
deployForce(); | ||
myDeploy(); | ||
}, 'deploy app'); | ||
task('deploy', true) | ||
}, 'deploy app without travis build check'); | ||
new Task('deploy:rollback', function(){ | ||
deployRollback(); | ||
task('deploy:restart'); | ||
}, 'deploy rollback'); | ||
new Helper(function myDeploy(){ | ||
@@ -19,10 +26,10 @@ //ssh('[ -f {{sharedPath}}/config/{{env}}.json ] && ln -s {{sharedPath}}/config/{{env}}.json {{releasePath}}/config/{{env}}.json'); | ||
task('deploy:restart'); | ||
}) | ||
}); | ||
new Task('deploy:rollback', function(){ | ||
deployRollback(); | ||
task('deploy:restart'); | ||
}, 'deploy rollback'); | ||
new Task('deploy:symlink', function(){ | ||
ssh('cd {{currentPath}} && NODE_ENV={{env}} sh ./rotator.sh'); | ||
}, 'create symlink to shared from current'); | ||
new Task('deploy:restart', function(){ | ||
@@ -69,4 +76,59 @@ ssh('cd {{currentPath}} && NODE_ENV={{env}} sh ./rotator.sh'); | ||
new Task('memcached:flush', function(data){ | ||
console.log(get('memcached.servers')); | ||
ssh('(echo flush_all; echo quit) | nc {{memcached.servers[0].host}} {{memcached.servers[0].port}}'); | ||
console.log(get('memcached')); | ||
ssh('(echo flush_all; echo quit) | nc {{memcached.host}} {{memcached.port}}'); | ||
}) | ||
new Helper(function sum(){ | ||
var sum = 0; | ||
for (var i in arguments) sum += arguments[i]; | ||
return sum; | ||
}) | ||
new Helper(function avg(){ | ||
return sum.apply(null, arguments) / arguments.length; | ||
}) | ||
new Task('dump:mysql', function(tables_only){ | ||
var mysql = get('mysql'); | ||
set('dumpName', ['dump', get('timestamp'), mysql.dbname].join('_') + '.sql.bz2'); | ||
var mysqldump_params = ''; | ||
var table_options = ''; | ||
if (tables_only) { | ||
table_options = [mysql.dbname, tables_only].join(' '); | ||
} else { | ||
table_options = [ | ||
mysql.dbname, | ||
'fin_transactions', | ||
'fin_operations', | ||
'fin_cash_accounts', | ||
'mongo_imports', | ||
'transactions', | ||
'referers', | ||
'video_referers', | ||
'cities', | ||
'countries', | ||
'acc_accounts', | ||
'acc_operations', | ||
'acc_operations_bil_transactions', | ||
'acc_operations_transactions', | ||
'acc_transactions' | ||
].join(' --ignore-table=' + mysql.dbname + '.') | ||
} | ||
mysqldump_params = [ | ||
'--force --disable-keys', | ||
'--host=' + mysql.host, | ||
'--user=' + mysql.username, | ||
'--password=' + mysql.password | ||
].join(' ') | ||
console.log(get('cwd')) | ||
ssh('/usr/bin/mysqldump ' + mysqldump_params + ' ' + table_options + ' | bzip2 > {{sharedPath}}/{{dumpName}}'); | ||
//ssh('mv {{sharedPath}}/{{dumpName}} {{currentPath}}/public'); | ||
//local('node boom local memcached:flush --branch={{branch}} --local'); | ||
env('dev'); | ||
task('memcached:flush') | ||
}) |
@@ -90,13 +90,2 @@ new Task('deploy:setup', function(){ | ||
//ssh('ls -1dt {{releasesPath}}/* | tail -n +{{keepReleases+1}} | xargs rm -rf'); | ||
}); | ||
new Helper(function sum(){ | ||
var sum = 0; | ||
for (var i in arguments) sum += arguments[i]; | ||
return sum; | ||
}) | ||
new Helper(function avg(){ | ||
return sum.apply(null, arguments) / arguments.length; | ||
}) | ||
}); |
@@ -54,3 +54,3 @@ var _ = require('lodash'); | ||
exports.go = function(env, taskname){ | ||
exports.go = function(env, taskname, args){ | ||
@@ -61,14 +61,21 @@ config.init(env); | ||
exports.prepare(function(){ | ||
exports.perform(taskname); | ||
exports.perform(taskname, args); | ||
}) | ||
}; | ||
exports.perform = function(taskname){ | ||
exports.perform = function(taskname, args){ | ||
exports.executors.task(taskname, [], function(err){ | ||
exports.executors.task(taskname, args||[], function(err){ | ||
// console.log(config.get()); | ||
// console.log(scope); | ||
if (err && err.exit) console.log($('EXIT:').bold.cyan, err.message); | ||
else if (err) return console.error($('FAIL.').bold.red + ' ' + err); | ||
else console.log($('SUCCESS.').bold.green); | ||
if (err) { | ||
if (err.exit) { | ||
console.log($('EXIT:').bold.cyan, err.message); | ||
} else { | ||
console.error($('FAIL.').bold.red + ' ' + err); | ||
process.exit(1); | ||
} | ||
} else { | ||
console.log($('SUCCESS.').bold.green); | ||
} | ||
if (config.sudoStored) { | ||
@@ -75,0 +82,0 @@ spawnProcess.ssh('rm -f ' + config.sudoPath, function(){ |
@@ -78,3 +78,3 @@ var _ = require('lodash'); | ||
}, | ||
createToken: function(cb){ | ||
createToken: function(callback){ | ||
var self = this; | ||
@@ -87,24 +87,39 @@ readline.askGithubHttpAuth(function(err, username, password){ | ||
}); | ||
self.api.authorization.create({ | ||
scopes: ['user', 'repo'], | ||
note: 'boom-deploy', | ||
}, function(err, res) { | ||
if (err) { | ||
var msg = JSON.parse(err.message); | ||
if (err.code == 422) { | ||
self.api.authorization.getAll({}, function(err, res){ | ||
if (err) return cb(err); | ||
var token = _.find(res, {note: 'boom-deploy'}); | ||
if (!token) return cb('cannot find token on first page'); | ||
cb(null, token.token); | ||
}) | ||
var otp_code = null; | ||
function create(cb){ | ||
self.api.authorization.create({ | ||
scopes: ['user', 'repo'], | ||
note: 'boom-deploy', | ||
headers: { 'X-GitHub-OTP': otp_code } | ||
}, function(err, res) { | ||
if (err) { | ||
var msg = JSON.parse(err.message); | ||
if (err.code == 422) { | ||
self.api.authorization.getAll({ headers: { 'X-GitHub-OTP': otp_code } }, function(err, res){ | ||
if (err) return callback(err); | ||
var token = _.find(res, {note: 'boom-deploy'}); | ||
if (!token) return callback('cannot find token on first page'); | ||
callback(null, token.token); | ||
}) | ||
} else if (msg.message == 'Must specify two-factor authentication OTP code.') { | ||
readline.askOTPcode(function(err, code){ | ||
otp_code = code; | ||
if (err) return callback(err); | ||
create(callback); | ||
}); | ||
} else { | ||
callback(msg.message); | ||
} | ||
} else { | ||
cb(msg.message); | ||
callback(null, res.token); | ||
} | ||
} else { | ||
cb(null, res.token); | ||
} | ||
}); | ||
}) | ||
}); | ||
} | ||
create(); | ||
}) | ||
} | ||
} |
@@ -20,2 +20,5 @@ var read = require('read'); | ||
}, | ||
askOTPcode: function(cb){ | ||
read({ prompt: 'OTP code: ' }, cb); | ||
}, | ||
askYesOrNot: function(question, cb){ | ||
@@ -22,0 +25,0 @@ var self = this; |
@@ -172,2 +172,5 @@ var _ = require('lodash'); | ||
}().wait() | ||
}, | ||
env: function(env){ | ||
config.init(env); | ||
} | ||
@@ -174,0 +177,0 @@ } |
@@ -31,2 +31,5 @@ var moment = require('moment'); | ||
return path.resolve(this.releasesPath||'', this.timestamp) | ||
}, | ||
cwd: function(){ | ||
return process.cwd() | ||
} | ||
@@ -33,0 +36,0 @@ } |
{ | ||
"name": "boom-deploy", | ||
"main": "boom.js", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "deploy your app", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41169
27
1208