Created
April 9, 2012 09:04
-
-
Save atsuya/2342429 to your computer and use it in GitHub Desktop.
roco example
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 characters
ensure 'env', 'development' | |
set 'branch', 'master' | |
set 'nodeEntry', 'server.js' | |
ensure('nvmPath', '/home/deployer/nvm') | |
ensure('nvmNodeVersion', '0.6.7') | |
# | |
# development | |
# | |
if roco.env == 'development' | |
set 'hosts', ['deployer@localhost:22'] | |
set 'deployTo', '/home/deployer/example' | |
set 'nvmPath', '/home/deployer/nvm' | |
set 'nvmNodeVersion', '0.6.14' | |
# | |
# integration | |
# | |
else if roco.env == 'integration' | |
set 'hosts', ['[email protected]'] | |
set 'deployTo', '/home/deployer/test/example' | |
set 'nvmPath', '/home/deployer/test/nvm' | |
set 'nvmNodeVersion', '0.6.7' | |
# | |
# staging | |
# | |
else if roco.env == 'staging' | |
set 'hosts', ['[email protected]'] | |
set 'deployTo', '/data/example' | |
set 'nvmPath', '/home/deployer/nvm' | |
set 'nvmNodeVersion', '0.6.7' | |
# | |
# production | |
# | |
else if roco.env == 'production' | |
set 'hosts', ['[email protected]:1982'] | |
set 'deployTo', '/data/example' | |
set 'nvmPath', '/home/deployer/nvm' | |
set 'nvmNodeVersion', '0.6.7' | |
set 'nvmUse', "cd #{roco.nvmPath}; . ./nvm.sh;" | |
namespace 'deploy', -> | |
task 'start', (done) -> sequence 'foreverStart', done | |
task 'stop', (done) -> sequence 'foreverStop', done | |
task 'restart', (done) -> sequence 'stop', 'start', done | |
task 'updateCode', (done) -> | |
localRun "git ls-remote #{roco.repository} #{roco.branch}", (x) -> | |
head = x.split(/\s+/).shift() | |
run """ | |
if [ -d #{roco.sharedPath}/cached-copy ]; | |
then cd #{roco.sharedPath}/cached-copy && | |
git fetch -q origin && git fetch --tags -q origin && | |
git reset -q --hard #{head} && git clean -q -d -x -f; | |
else | |
git clone -q #{roco.repository} #{roco.sharedPath}/cached-copy && | |
cd #{roco.sharedPath}/cached-copy && | |
git checkout -q -b deploy #{head}; | |
fi | |
""", -> | |
run """ | |
#{roco.nvmUse} | |
cd #{roco.sharedPath}/cached-copy; | |
npm install -l; | |
cp -RPp #{roco.sharedPath}/cached-copy #{roco.releasePath} | |
""", done | |
task 'foreverStart', (done) -> | |
#run "cd #{roco.currentPath}; forever start server.js" | |
console.log('forever!') | |
console.log(roco.nvmPath) | |
run """ | |
#{roco.nvmUse} | |
cd #{roco.currentPath}; | |
NODE_ENV=#{roco.env} ./node_modules/forever/bin/forever start #{roco.nodeEntry}; | |
""", done | |
task 'foreverStop', (done) -> | |
#run "cd #{roco.currentPath}; forever stop" | |
console.log('stop!') | |
run """ | |
#{roco.nvmUse} | |
cd #{roco.currentPath}; | |
./node_modules/forever/bin/forever stop 0 | |
""", done | |
task 'foreverList', (done) -> | |
run """ | |
#{roco.nvmUse} | |
cd #{roco.currentPath}; | |
./node_modules/forever/bin/forever list; | |
""", done | |
task 'status', (done) -> sequence 'foreverList', done | |
task 'nvm', (done) -> | |
run """ | |
cd #{roco.nvmPath}; | |
. ./nvm.sh; | |
nvm alias default #{roco.nvmNodeVersion}; | |
""", -> | |
console.log("nvm is set to use node #{roco.nvmNodeVersion}.") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment