staging.rb 2.1 KB

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