Guest User

Untitled

a guest
Sep 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. ensure 'env', 'development'
  2.  
  3. set 'branch', 'master'
  4. set 'nodeEntry', 'server.js'
  5.  
  6. ensure('nvmPath', '/home/deployer/nvm')
  7. ensure('nvmNodeVersion', '0.6.7')
  8.  
  9. #
  10. # development
  11. #
  12. if roco.env == 'development'
  13. set 'hosts', ['deployer@localhost:22']
  14. set 'deployTo', '/home/deployer/example'
  15. set 'nvmPath', '/home/deployer/nvm'
  16. set 'nvmNodeVersion', '0.6.14'
  17. #
  18. # integration
  19. #
  20. else if roco.env == 'integration'
  21. set 'hosts', ['deployer@example.com']
  22. set 'deployTo', '/home/deployer/test/example'
  23. set 'nvmPath', '/home/deployer/test/nvm'
  24. set 'nvmNodeVersion', '0.6.7'
  25. #
  26. # staging
  27. #
  28. else if roco.env == 'staging'
  29. set 'hosts', ['deployer@example.com']
  30. set 'deployTo', '/data/example'
  31. set 'nvmPath', '/home/deployer/nvm'
  32. set 'nvmNodeVersion', '0.6.7'
  33. #
  34. # production
  35. #
  36. else if roco.env == 'production'
  37. set 'hosts', ['deployer@example.com:1982']
  38. set 'deployTo', '/data/example'
  39. set 'nvmPath', '/home/deployer/nvm'
  40. set 'nvmNodeVersion', '0.6.7'
  41.  
  42. set 'nvmUse', "cd #{roco.nvmPath}; . ./nvm.sh;"
  43.  
  44. namespace 'deploy', ->
  45. task 'start', (done) -> sequence 'foreverStart', done
  46.  
  47. task 'stop', (done) -> sequence 'foreverStop', done
  48.  
  49. task 'restart', (done) -> sequence 'stop', 'start', done
  50.  
  51. task 'updateCode', (done) ->
  52. localRun "git ls-remote #{roco.repository} #{roco.branch}", (x) ->
  53. head = x.split(/\s+/).shift()
  54. run """
  55. if [ -d #{roco.sharedPath}/cached-copy ];
  56. then cd #{roco.sharedPath}/cached-copy &&
  57. git fetch -q origin && git fetch --tags -q origin &&
  58. git reset -q --hard #{head} && git clean -q -d -x -f;
  59. else
  60. git clone -q #{roco.repository} #{roco.sharedPath}/cached-copy &&
  61. cd #{roco.sharedPath}/cached-copy &&
  62. git checkout -q -b deploy #{head};
  63. fi
  64. """, ->
  65. run """
  66. #{roco.nvmUse}
  67. cd #{roco.sharedPath}/cached-copy;
  68. npm install -l;
  69. cp -RPp #{roco.sharedPath}/cached-copy #{roco.releasePath}
  70. """, done
  71.  
  72. task 'foreverStart', (done) ->
  73. #run "cd #{roco.currentPath}; forever start server.js"
  74. console.log('forever!')
  75. console.log(roco.nvmPath)
  76. run """
  77. #{roco.nvmUse}
  78. cd #{roco.currentPath};
  79. NODE_ENV=#{roco.env} ./node_modules/forever/bin/forever start #{roco.nodeEntry};
  80. """, done
  81.  
  82. task 'foreverStop', (done) ->
  83. #run "cd #{roco.currentPath}; forever stop"
  84. console.log('stop!')
  85. run """
  86. #{roco.nvmUse}
  87. cd #{roco.currentPath};
  88. ./node_modules/forever/bin/forever stop 0
  89. """, done
  90.  
  91. task 'foreverList', (done) ->
  92. run """
  93. #{roco.nvmUse}
  94. cd #{roco.currentPath};
  95. ./node_modules/forever/bin/forever list;
  96. """, done
  97.  
  98. task 'status', (done) -> sequence 'foreverList', done
  99.  
  100. task 'nvm', (done) ->
  101. run """
  102. cd #{roco.nvmPath};
  103. . ./nvm.sh;
  104. nvm alias default #{roco.nvmNodeVersion};
  105. """, ->
  106. console.log("nvm is set to use node #{roco.nvmNodeVersion}.")
  107. done
Add Comment
Please, Sign In to add comment