Guest User

Untitled

a guest
Jun 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #
  2. # This is a default deploy.rb
  3. # it is included into the Rails 3 Basic Template by default.
  4. #
  5.  
  6. require 'active_support'
  7. require 'lib/deploy_helpers'
  8.  
  9. DEPLOY_CONFIG = YAML::load(File.open("#{Rails.root}/config/deploy.yml"))
  10.  
  11. default_run_options[:pty] = true
  12. default_run_options[:max_hosts] = 2
  13.  
  14. # Make some defaults so we don't have to put everything in deploy.yml
  15. set :use_sudo, false
  16. set :scm, :git
  17. set :deploy_via, :remote_cache
  18. set :application, DEPLOY_CONFIG['application']
  19. set :repository, DEPLOY_CONFIG['repository']
  20.  
  21. # Load recipes
  22. DEPLOY_CONFIG['recipes'].split(',').each{ |r| require "#{r.chomp}" }
  23.  
  24. # Setup each location
  25. DEPLOY_CONFIG['locations'].each_pair do |location, settings|
  26.  
  27. task "#{location}" do
  28. settings.each_pair do |key, value|
  29. set key.to_sym, value
  30. end
  31.  
  32. domain.to_s.split(',').each{ |d| role(:app, d) }
  33. domain.to_s.split(',').each{ |d| role(:web, d) }
  34.  
  35. unless settings['db_server']
  36. domain.to_s.split(',').each{ |d| role(:db, d, :primary => true) }
  37. else
  38. role :db, settings['db_server'], :primary => true, :no_release => true
  39. end
  40.  
  41. end
  42.  
  43. end
  44.  
  45. after "deploy:update_code","deploy:symlink_configs" # Symlink configuration files into the shared folder
  46. after 'deploy:restart', 'deploy:cleanup' # Make sure our releases don't get out of control.
  47.  
  48. namespace :deploy do
  49.  
  50. # Symlink our database config and any other files in the "configs" list in deploy.yml
  51. task :symlink_configs, :roles => :app do
  52.  
  53. configurations = DEPLOY_CONFIG['configs'].split(",")
  54.  
  55. unless configurations.empty?
  56. configs = configurations.collect{ |file| "ln -nfs #{shared_path}/config/#{file} #{release_path}/config/#{file.chomp}" }
  57. run "mkdir -p #{shared_path}/config && cd #{release_path} && #{configs.join(" && ")}"
  58. end
  59.  
  60. run "mkdir -p #{shared_path}/cache && cd #{release_path} && ln -nfs #{shared_path}/cache #{release_path}/tmp/cache"
  61. run "mkdir -p #{shared_path}/pids && cd #{release_path} && ln -nfs #{shared_path}/pids #{release_path}/tmp/pids"
  62.  
  63. # If an asset path is defined, link that one to our system dir instead.
  64. if defined?(asset_path) && path_exists?("#{asset_path}")
  65. run "cd #{release_path} && ln -nfs #{asset_path} #{release_path}/public/system"
  66. else
  67. run "cd #{release_path} && ln -nfs #{shared_path}/system #{release_path}/public/system"
  68. end
  69.  
  70. end
  71.  
  72. end
Add Comment
Please, Sign In to add comment