PageRenderTime 71ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/config/deploy.rb

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