Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # This is a default deploy.rb
- # it is included into the Rails 3 Basic Template by default.
- #
- require 'active_support'
- require 'lib/deploy_helpers'
- DEPLOY_CONFIG = YAML::load(File.open("#{Rails.root}/config/deploy.yml"))
- default_run_options[:pty] = true
- default_run_options[:max_hosts] = 2
- # Make some defaults so we don't have to put everything in deploy.yml
- set :use_sudo, false
- set :scm, :git
- set :deploy_via, :remote_cache
- set :application, DEPLOY_CONFIG['application']
- set :repository, DEPLOY_CONFIG['repository']
- # Load recipes
- DEPLOY_CONFIG['recipes'].split(',').each{ |r| require "#{r.chomp}" }
- # Setup each location
- DEPLOY_CONFIG['locations'].each_pair do |location, settings|
- task "#{location}" do
- settings.each_pair do |key, value|
- set key.to_sym, value
- end
- domain.to_s.split(',').each{ |d| role(:app, d) }
- domain.to_s.split(',').each{ |d| role(:web, d) }
- unless settings['db_server']
- domain.to_s.split(',').each{ |d| role(:db, d, :primary => true) }
- else
- role :db, settings['db_server'], :primary => true, :no_release => true
- end
- end
- end
- after "deploy:update_code","deploy:symlink_configs" # Symlink configuration files into the shared folder
- after 'deploy:restart', 'deploy:cleanup' # Make sure our releases don't get out of control.
- namespace :deploy do
- # Symlink our database config and any other files in the "configs" list in deploy.yml
- task :symlink_configs, :roles => :app do
- configurations = DEPLOY_CONFIG['configs'].split(",")
- unless configurations.empty?
- configs = configurations.collect{ |file| "ln -nfs #{shared_path}/config/#{file} #{release_path}/config/#{file.chomp}" }
- run "mkdir -p #{shared_path}/config && cd #{release_path} && #{configs.join(" && ")}"
- end
- run "mkdir -p #{shared_path}/cache && cd #{release_path} && ln -nfs #{shared_path}/cache #{release_path}/tmp/cache"
- run "mkdir -p #{shared_path}/pids && cd #{release_path} && ln -nfs #{shared_path}/pids #{release_path}/tmp/pids"
- # If an asset path is defined, link that one to our system dir instead.
- if defined?(asset_path) && path_exists?("#{asset_path}")
- run "cd #{release_path} && ln -nfs #{asset_path} #{release_path}/public/system"
- else
- run "cd #{release_path} && ln -nfs #{shared_path}/system #{release_path}/public/system"
- end
- end
- end
Add Comment
Please, Sign In to add comment