Skip to content

Instantly share code, notes, and snippets.

@werelax
Created September 5, 2016 20:42
Show Gist options
  • Save werelax/866a98102e5ef2126dc5be40d258c041 to your computer and use it in GitHub Desktop.
Save werelax/866a98102e5ef2126dc5be40d258c041 to your computer and use it in GitHub Desktop.
Simple Flightplan script for simple node.js deployments
'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