PageRenderTime 25ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/config/deploy.rb

https://bitbucket.org/upcodeacademy/hdbnb
Ruby | 84 lines | 61 code | 11 blank | 12 comment | 1 complexity | 25b88776846a839f4aaea62f100c723a MD5 | raw file
  1. server '128.199.123.22', roles: [:web, :app, :db], primary: true
  2. set :repo_url, 'git@bitbucket.org:upcodeacademy/hdbnb.git'
  3. set :application, 'hdbnb'
  4. set :user, 'deploy'
  5. set :puma_threads, [4, 16]
  6. set :puma_workers, 2
  7. # Don't change these unless you know what you're doing
  8. set :pty, true
  9. set :use_sudo, false
  10. set :stage, :production
  11. set :deploy_via, :remote_cache
  12. set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
  13. set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
  14. set :puma_state, "#{shared_path}/tmp/pids/puma.state"
  15. set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
  16. set :puma_access_log, "#{release_path}/log/puma.error.log"
  17. set :puma_error_log, "#{release_path}/log/puma.access.log"
  18. set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
  19. set :puma_preload_app, true
  20. set :puma_worker_timeout, nil
  21. set :puma_init_active_record, true # Change to false when not using ActiveRecord
  22. ## Defaults:
  23. # set :scm, :git
  24. # set :branch, :master
  25. # set :format, :pretty
  26. # set :log_level, :debug
  27. # set :keep_releases, 5
  28. ## Linked Files & Directories (Default None):
  29. set :linked_files, %w{config/secrets.yml config/database.yml}
  30. # set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
  31. namespace :puma do
  32. desc 'Create Directories for Puma Pids and Socket'
  33. task :make_dirs do
  34. on roles(:app) do
  35. execute "mkdir #{shared_path}/tmp/sockets -p"
  36. execute "mkdir #{shared_path}/tmp/pids -p"
  37. execute "mkdir #{shared_path}/log -p"
  38. end
  39. end
  40. before :start, :make_dirs
  41. end
  42. namespace :deploy do
  43. desc "Make sure local git is in sync with remote."
  44. task :check_revision do
  45. on roles(:app) do
  46. unless `git rev-parse HEAD` == `git rev-parse origin/master`
  47. puts "WARNING: HEAD is not the same as origin/master"
  48. puts "Run `git push` to sync changes."
  49. exit
  50. end
  51. end
  52. end
  53. desc 'Initial Deploy'
  54. task :initial do
  55. on roles(:app) do
  56. before 'deploy:restart', 'puma:start'
  57. invoke 'deploy'
  58. end
  59. end
  60. desc 'Restart application'
  61. task :restart do
  62. on roles(:app), in: :sequence, wait: 5 do
  63. invoke 'puma:restart'
  64. end
  65. end
  66. before :starting, :check_revision
  67. after :finishing, :compile_assets
  68. after :finishing, :cleanup
  69. after :finishing, :restart
  70. end
  71. # ps aux | grep puma # Get puma pid
  72. # kill -s SIGUSR2 pid # Restart puma
  73. # kill -s SIGTERM pid # Stop puma