Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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', ['deployer@example.com']
- 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', ['deployer@example.com']
- set 'deployTo', '/data/example'
- set 'nvmPath', '/home/deployer/nvm'
- set 'nvmNodeVersion', '0.6.7'
- #
- # production
- #
- else if roco.env == 'production'
- set 'hosts', ['deployer@example.com: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
Add Comment
Please, Sign In to add comment