deploy.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. require 'dotenv'
  2. Dotenv.load
  3. # config valid only for current version of Capistrano
  4. lock '3.11.0'
  5. set :application, 'huginn'
  6. set :repo_url, ENV['CAPISTRANO_DEPLOY_REPO_URL'] || 'https://github.com/huginn/huginn.git'
  7. # Default branch is :master
  8. set :branch, ENV['CAPISTRANO_DEPLOY_BRANCH'] || ENV['BRANCH'] || 'master'
  9. set :deploy_to, '/home/huginn'
  10. # Set to :debug for verbose ouput
  11. set :log_level, :info
  12. # Default value for :linked_files is []
  13. set :linked_files, fetch(:linked_files, []).push('.env', 'Procfile', 'config/unicorn.rb')
  14. # Default value for linked_dirs is []
  15. set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle')
  16. # Default value for keep_releases is 5
  17. # set :keep_releases, 5
  18. set :bundle_jobs, 4
  19. set :conditionally_migrate, true # Defaults to false. If true, it's skip migration if files in db/migrate not modified
  20. task :deploy => [:production]
  21. namespace :deploy do
  22. after 'check:make_linked_dirs', :migrate_to_cap do
  23. on roles(:all) do
  24. # Try to migrate from the manual installation to capistrano directory structure
  25. next if test('[ -L ~/huginn ]')
  26. fetch(:linked_files).each do |f|
  27. if !test("[ -f ~/shared/#{f} ] ") && test("[ -f ~/huginn/#{f} ]")
  28. execute("cp ~/huginn/#{f} ~/shared/#{f}")
  29. end
  30. end
  31. execute('mv ~/huginn ~/huginn.manual')
  32. execute('ln -s ~/current ~/huginn')
  33. end
  34. end
  35. after :publishing, :restart do
  36. on roles(:all) do
  37. within release_path do
  38. execute :rake, 'production:restart'
  39. end
  40. end
  41. end
  42. end