Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.72 KB | None | 0 0
  1. # config valid only for current version of Capistrano
  2. lock '3.3.5'
  3.  
  4. set :rails_env, :staging
  5.  
  6. # Change these
  7. server '178.62.89.186', roles: [:app, :db], primary: true
  8.  
  9. set :repo_url,        'git@bitbucket.org:gtravel/gtravel-core.git'
  10. set :application,     'gtravel'
  11. set :user,            'deploy'
  12. set :puma_threads,    [4, 16]
  13. set :puma_workers,    0
  14.  
  15. # Don't change these unless you know what you're doing
  16. set :pty,             true
  17. set :use_sudo,        false
  18. set :stage,           :staging
  19. set :deploy_via,      :remote_cache
  20. set :deploy_to,       "/home/#{fetch(:user)}/#{fetch(:application)}"
  21. set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
  22. set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
  23. set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
  24. set :puma_access_log, "#{release_path}/log/puma.error.log"
  25. set :puma_error_log,  "#{release_path}/log/puma.access.log"
  26. set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
  27. set :puma_preload_app, true
  28. set :puma_worker_timeout, nil
  29. set :puma_init_active_record, true  # Change to true if using ActiveRecord
  30.  
  31. ## Defaults:
  32. # set :scm,           :git
  33. set :branch,        :master
  34. set :format,        :pretty
  35. set :log_level,     :debug
  36. set :keep_releases, 2
  37. set :rbenv_path, '/home/deploy/.rbenv'
  38. set :rbenv_ruby, '2.1.2'
  39.  
  40.  
  41. ## Linked Files & Directories (Default None):
  42.  set :linked_files, %w{config/database.yml config/application.yml config/nginx.conf}
  43. # set :linked_dirs,  %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
  44.  
  45. namespace :puma do
  46.   desc 'Create Directories for Puma Pids and Socket'
  47.   task :make_dirs do
  48.     on roles(:app) do
  49.       execute "mkdir #{shared_path}/tmp/sockets -p"
  50.       execute "mkdir #{shared_path}/tmp/pids -p"
  51.     end
  52.   end
  53.  
  54.   before :start, :make_dirs
  55. end
  56.  
  57. namespace :deploy do
  58.   desc "Make sure local git is in sync with remote."
  59.   task :check_revision do
  60.     on roles(:app) do
  61.       unless `git rev-parse HEAD` == `git rev-parse origin/master`
  62.         puts "WARNING: HEAD is not the same as origin/master"
  63.         puts "Run `git push` to sync changes."
  64.         exit
  65.       end
  66.     end
  67.   end
  68.  
  69.   desc 'Initial Deploy'
  70.   task :initial do
  71.     on roles(:app) do
  72.       before 'deploy:restart', 'puma:start'
  73.       invoke 'deploy'
  74.     end
  75.   end
  76.  
  77.   desc 'Restart application'
  78.   task :restart do
  79.     on roles(:app), in: :sequence, wait: 5 do
  80.       invoke 'puma:restart'
  81.     end
  82.   end
  83.  
  84.   before :starting,     :check_revision
  85.   after  :finishing,    :cleanup
  86.   after  :finishing,    :restart
  87. end
  88.  
  89. # ps aux | grep puma    # Get puma pid
  90. # kill -s SIGUSR2 pid   # Restart puma
  91. # kill -s SIGTERM pid   # Stop puma
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement