PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/old_cap/deploy.rb

https://bitbucket.org/hackmyfuture/venuecenter
Ruby | 84 lines | 61 code | 11 blank | 12 comment | 1 complexity | 659da515fd08a84b0084b821c7290a5d MD5 | raw file
  1. # Change these
  2. server 'webby1.venuecenter.com', port: 22, roles: %i[web app db], primary: true
  3. set :repo_url, 'git@bitbucket.org:venuecenter/venuecenter.git'
  4. set :application, 'venuecenter'
  5. set :user, 'serveradmin'
  6. set :puma_threads, [4, 16]
  7. set :puma_workers, 0
  8. # Don't change these unless you know what you're doing
  9. set :pty, true
  10. set :use_sudo, false
  11. set :stage, :production
  12. set :deploy_via, :remote_cache
  13. set :deploy_to, "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
  14. set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
  15. set :puma_state, "#{shared_path}/tmp/pids/puma.state"
  16. set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
  17. set :puma_access_log, "#{release_path}/log/puma.error.log"
  18. set :puma_error_log, "#{release_path}/log/puma.access.log"
  19. set :ssh_options, forward_agent: true, user: fetch(:user), keys: %w[~/.ssh/id_rsa.pub]
  20. set :puma_preload_app, true
  21. set :puma_worker_timeout, nil
  22. set :puma_init_active_record, true # Change to false when not using ActiveRecord
  23. ## Defaults:
  24. set :scm, :git
  25. set :branch, :master
  26. # set :format, :pretty
  27. # set :log_level, :debug
  28. # set :keep_releases, 5
  29. ## Linked Files & Directories (Default None):
  30. # set :linked_files, %w{config/database.yml}
  31. # set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
  32. namespace :puma do
  33. desc 'Create Directories for Puma Pids and Socket'
  34. task :make_dirs do
  35. on roles(:app) do
  36. execute "mkdir #{shared_path}/tmp/sockets -p"
  37. execute "mkdir #{shared_path}/tmp/pids -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