staging.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # encoding: UTF-8
  2. set :stage, :staging
  3. # Simple Role Syntax
  4. # ==================
  5. # Supports bulk-adding hosts to roles, the primary
  6. # server in each group is considered to be the first
  7. # unless any hosts have the primary property set.
  8. role :all, %w{discite@alt.ceata.org}
  9. set :branch, :master
  10. # will be set to branch staging, probably
  11. set :deploy_to, "/home/discite/#{fetch(:stage)}"
  12. set :keep_releases, 2
  13. set :control_directory, '/home/discite'
  14. set :format, :pretty
  15. set :log_level, :debug
  16. set :default_env, path: "#{release_path}/bin:/home/discite/.rvm/bin:/home/discite/.nvm/bin:$PATH"
  17. after 'deploy:updating', 'deploy:bundle'
  18. puma_sock = "unix://#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/puma.sock"
  19. puma_control = "unix://#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/pumactl.sock"
  20. puma_state = "#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/puma.state"
  21. puma_log = "#{fetch(:control_directory)}/#{fetch(:stage)}/log/puma.log"
  22. namespace :deploy do
  23. task :setup do
  24. on roles(:app) do
  25. within release_path do
  26. execute "mkdir -p #{fetch(:control_directory)}/#{fetch(:stage)}/{log,sockets}"
  27. end
  28. end
  29. end
  30. task :bundle do
  31. on roles(:app) do
  32. within release_path do
  33. execute :bundle, 'install --quiet --without [:test, :development]'
  34. end
  35. end
  36. end
  37. task :start do
  38. on roles(:all) do
  39. within release_path do
  40. execute :puma,
  41. "-b #{puma_sock}",
  42. '-e production',
  43. '-t 2:4',
  44. "--control #{puma_control}",
  45. "-S #{puma_state} >> #{puma_log} 2>&1 &"
  46. end
  47. end
  48. end
  49. task :stop do
  50. on roles(:all) do
  51. within release_path do
  52. execute :pumactl, "-S #{puma_state} stop"
  53. end
  54. end
  55. end
  56. task :restart do
  57. on roles(:all) do
  58. within release_path do
  59. execute :pumactl, "-S #{puma_state} restart"
  60. end
  61. end
  62. end
  63. task :compile_assets do
  64. on roles(:all) do
  65. within release_path do
  66. execute :rake, 'assets:precompile'
  67. end
  68. end
  69. end
  70. task :status do
  71. on roles(:all) do
  72. within release_path do
  73. execute :pumactl, "-S #{puma_state} stats"
  74. end
  75. end
  76. end
  77. end