Created
September 5, 2016 20:42
-
-
Save werelax/866a98102e5ef2126dc5be40d258c041 to your computer and use it in GitHub Desktop.
Simple Flightplan script for simple node.js deployments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const plan = require('flightplan'); | |
// ------------------------- | |
// Targets | |
plan.target('dev', { | |
host: 'viviz.bettr.es', | |
username: 'elias', | |
privateKey: '../config/development.pem', | |
}); | |
plan.target('production', { | |
host: 'viviz-prod.bettr.es', | |
username: 'viviz', | |
privateKey: '../config/production.pem', | |
}); | |
// ------------------------- | |
// Tasks | |
plan.remote('stop', (remote) => { | |
remote.with('cd /var/www/viviz/', () => { | |
remote.log('* Stop bot server'); | |
remote.exec('./node_modules/.bin/pm2 stop 0'); | |
}); | |
}); | |
plan.remote('start', (remote) => { | |
remote.with('cd /var/www/viviz/', () => { | |
remote.log('* Start bot server'); | |
remote.exec('./node_modules/.bin/pm2 start src/index.js'); | |
}); | |
}); | |
plan.remote('deploy', (remote) => { | |
remote.with('cd /var/www/viviz/', () => { | |
remote.log('* Pull updates'); | |
remote.exec('git pull origin master --ff-only'); | |
remote.log('* Update dependencies'); | |
remote.exec('npm install'); | |
remote.log('* Stop bot server'); | |
remote.exec('./node_modules/.bin/pm2 stop 0 || true'); | |
remote.log('* Start bot server'); | |
remote.exec('./node_modules/.bin/pm2 start src/index.js'); | |
}); | |
}); | |
plan.remote('default', ['start', 'deploy', 'stop']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment