production.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # encoding: UTF-8
  2. set :stage, :production
  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 :web, %w(discite@alt.ceata.org)
  9. role :app, %w(discite@alt.ceata.org)
  10. role :db, %w(discite@alt.ceata.org)
  11. set :rails_env, 'production'
  12. set :branch, :master
  13. set :deploy_to, "/home/discite/#{fetch(:stage)}"
  14. set :keep_releases, 2
  15. set :control_directory, '/home/discite'
  16. set :format, :pretty
  17. set :log_level, :debug
  18. set :default_env, path: "#{release_path}/bin:/home/discite/.rvm/bin:/home/discite/.nvm/bin:$PATH"
  19. puma_sock = "unix://#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/puma.sock"
  20. puma_control = "unix://#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/pumactl.sock"
  21. puma_state = "#{fetch(:control_directory)}/#{fetch(:stage)}/sockets/puma.state"
  22. puma_log = "#{fetch(:control_directory)}/#{fetch(:stage)}/log/puma.log"
  23. namespace :deploy do
  24. task :setup do
  25. on roles(:app) do
  26. within release_path do
  27. execute "mkdir -p #{fetch(:control_directory)}/#{fetch(:stage)}/{log,sockets}"
  28. end
  29. end
  30. end
  31. task :bundle do
  32. on roles(:app) do
  33. within release_path do
  34. with rails_env: fetch(:stage) do
  35. execute :bundle, 'install --quiet --without [:test, :development]'
  36. end
  37. end
  38. end
  39. end
  40. task :start do
  41. on roles(:all) do
  42. within release_path do
  43. with rails_env: fetch(:stage) do
  44. execute :bundle, :exec, :puma,
  45. "-b #{puma_sock}",
  46. '-e production',
  47. '-t 2:4',
  48. "--control #{puma_control}",
  49. "-S #{puma_state} >> #{puma_log} 2>&1 &"
  50. end
  51. end
  52. end
  53. end
  54. task :stop do
  55. on roles(:all) do
  56. within release_path do
  57. execute :pumactl, "-S #{puma_state} stop"
  58. end
  59. end
  60. end
  61. task :restart do
  62. on roles(:all) do
  63. within release_path do
  64. execute :pumactl, "-S #{puma_state} restart"
  65. end
  66. end
  67. end
  68. task :status do
  69. on roles(:all) do
  70. within release_path do
  71. execute :pumactl, "-S #{puma_state} stats"
  72. end
  73. end
  74. end
  75. end