Created
April 7, 2014 13:40
-
-
Save Termina1/10020494 to your computer and use it in GitHub Desktop.
Meteor flightplan for https://github.com/pstadler/flightplan
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
fs = require('fs') | |
Flightplan = require("./.node_modules/flightplan") # we need to install flightplane to .node_modules for meteor to ignore it | |
path = require('path') | |
plan = new Flightplan() | |
releaseFile = "release.tar.tgz" # name of the bundle generated by meteor | |
workPath = '/home/user/path' # path to the project folder | |
releaseFolder = 'rel' + Date.now() | |
releasePath = path.join(workPath, releaseFolder) | |
passengerIntegration = (remote) -> | |
bundle = path.join(releasePath, 'bundle') | |
remote.log 'Creating additional dirs for Passenger' | |
remote.exec "cd #{bundle} && mkdir public" | |
remote.exec "cd #{bundle} && mkdir tmp" | |
remote.exec "cd #{bundle} && touch tmp/restart.txt" | |
# configuration | |
plan.briefing | |
debug: false | |
destinations: | |
production: [ | |
{ | |
host: "destination.com" | |
username: "user" | |
agent: process.env.SSH_AUTH_SOCK | |
} | |
] | |
# run commands on localhost | |
plan.remote (remote) -> | |
remote.exec "cd #{workPath} && mkdir #{releaseFolder}" | |
plan.local (local) -> | |
local.log "Run meteor bundle" | |
local.exec "meteor bundle #{releaseFile}" | |
local.log "Copy files to remote hosts" | |
local.transfer [releaseFile], releasePath | |
# run commands on remote hosts (destinations) | |
plan.remote (remote) -> | |
remote.log "Extracting package" | |
remote.exec "cd #{releasePath} && tar -xzf #{releaseFile}" | |
remote.exec "cd #{releasePath} && rm #{releaseFile}" | |
remote.log "Installing fibers" | |
remote.exec "cd #{releasePath}/bundle/programs/server && npm install fibers" | |
passengerIntegration(remote) # some phusion passenger integration steps | |
remote.log "Relink current release dir to new directory" | |
remote.exec "cd #{workPath} && if [ -d current ] ; then rm current ; fi && ln -s #{releaseFolder} current" | |
remote.log "Remove all old releases" | |
remote.exec "cd #{workPath} && find . -maxdepth 1 -type d -not -name '#{releaseFolder}' -not -name '.' | xargs rm -rf" | |
plan.debriefing -> | |
fs.unlink releaseFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment