Forked from learncodeacademy/flightplan-deploy.md
Created
September 22, 2016 05:17
-
-
Save alexventuraio/2a524774be38e16d4b5984f7b244884a to your computer and use it in GitHub Desktop.
Revisions
-
learncodeacademy revised this gist
Dec 15, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,21 +21,21 @@ var tmpDir = appName+'-' + new Date().getTime(); plan.target('staging', [ { host: '104.131.93.214', username: username, agent: process.env.SSH_AUTH_SOCK } ]); plan.target('production', [ { host: '104.131.93.215', username: username, agent: process.env.SSH_AUTH_SOCK }, //add in another server if you have more than one // { // host: '104.131.93.216', // username: username, // agent: process.env.SSH_AUTH_SOCK // } ]); -
learncodeacademy revised this gist
Dec 15, 2014 . 1 changed file with 21 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,41 +9,36 @@ - create a flightplan.js file ```javascript var plan = require('flightplan'); var appName = 'node-app'; var username = 'deploy'; var startFile = 'bin/www'; var tmpDir = appName+'-' + new Date().getTime(); // configuration plan.target('staging', [ { host: '104.131.93.214', username: 'deploy', agent: process.env.SSH_AUTH_SOCK } ]); plan.target('production', [ { host: '104.131.93.215', username: 'deploy', agent: process.env.SSH_AUTH_SOCK }, //add in another server if you have more than one // { // host: '104.131.93.216', // username: 'deploy', // agent: process.env.SSH_AUTH_SOCK // } ]); // run commands on localhost plan.local(function(local) { -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -74,4 +74,7 @@ plan.remote(function(remote) { ``` ##Deploy! - `fly staging` or `fly production` ##Take it to the next level [Run your node app as a system service so it runs after server reboots](https://gist.github.com/learncodeacademy/3a96aa1226c769adba39) -
learncodeacademy renamed this gist
Oct 16, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
learncodeacademy revised this gist
Oct 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ##Setup your server (this would ideally be done with automated provisioning) - add a deploy user with password-less ssh [see this gist](https://gist.github.com/learncodeacademy/3cdb928c9314f98404d0) - install forever `npm install -g forever` ##Install flightplan -
learncodeacademy created this gist
Oct 15, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,77 @@ ##Setup your server (this would ideally be done with automated provisioning) - add a deploy user with password-less ssh - install forever `npm install -g forever` ##Install flightplan - `npm install -g flightplan` - in your project folder `npm install flightplan --save-dev` - create a flightplan.js file ```javascript var Flightplan = require('flightplan'); var appName = 'node-app'; var username = 'deploy'; var startFile = 'bin/www'; var tmpDir = appName+'-' + new Date().getTime(); var plan = new Flightplan(); // configuration plan.briefing({ debug: false, destinations: { 'staging': { host: '104.131.93.214', username: 'deploy', agent: process.env.SSH_AUTH_SOCK }, 'production': [ { host: '104.131.93.215', username: 'deploy', agent: process.env.SSH_AUTH_SOCK }, //add in another server if you have more than one // { // host: '104.131.93.216', // username: 'deploy', // agent: process.env.SSH_AUTH_SOCK // } ] } }); // run commands on localhost plan.local(function(local) { // uncomment these if you need to run a build on your machine first // local.log('Run build'); // local.exec('gulp build'); local.log('Copy files to remote hosts'); var filesToCopy = local.exec('git ls-files', {silent: true}); // rsync files to all the destination's hosts local.transfer(filesToCopy, '/tmp/' + tmpDir); }); // run commands on remote hosts (destinations) plan.remote(function(remote) { remote.log('Move folder to root'); remote.sudo('cp -R /tmp/' + tmpDir + ' ~', {user: username}); remote.rm('-rf /tmp/' + tmpDir); remote.log('Install dependencies'); remote.sudo('npm --production --prefix ~/' + tmpDir + ' install ~/' + tmpDir, {user: username}); remote.log('Reload application'); remote.sudo('ln -snf ~/' + tmpDir + ' ~/'+appName, {user: username}); remote.exec('forever stop ~/'+appName+'/'+startFile, {failsafe: true}); remote.exec('forever start ~/'+appName+'/'+startFile); }); ``` ##Deploy! - `fly staging` or `fly production`