Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set :stages, %w(staging production)
- set :default_stage, "staging"
- require 'capistrano/ext/multistage'
- set :use_sudo, false # deploy user should own the application directory
- set :user, 'deploy'
- set :runner, user
- default_run_options[:pty] = true
- ssh_options[:port] = 8910
- set :domain, '000.000.000.000'
- set :application, "myapp.com"
- set(:deploy_to) { "/var/www/public_html/#{application}/#{stage}" }
- set :scm, :git
- set :scm_verbose, true
- set :repository, 'git@github.com:myusername/myrepo.git'
- set :branch, 'master'
- set :deploy_via, :remote_cache
- role :app, domain
- role :web, domain
- role :db, domain, :primary => true
- namespace :deploy do
- desc "Restarting mod_rails with restart.txt"
- task :restart, :roles => :app, :except => { :no_release => true } do
- run "touch #{current_path}/tmp/restart.txt"
- end
- [:start, :stop].each do |t|
- desc "#{t} task is a no-op with mod_rails"
- task t, :roles => :app do ; end
- end
- end
- desc "Creates a generic database.yml in app/shared/conf"
- task :create_database_yml, :roles => :app do
- database_configuration = <<-EOF
- production:
- adapter: mysql
- database: app_production
- username:
- password:
- encoding: utf8
- socket: /var/run/mysqld/mysqld.sock
- staging:
- production
- EOF
- run "mkdir -p #{deploy_to}/#{shared_dir}/conf"
- put database_configuration, "#{deploy_to}/#{shared_dir}/conf/database.yml"
- end
- after "deploy:setup", :create_database_yml
- desc "Copy app/shared/conf/database.yml to new release/config/database.yml"
- task :copy_database_yml, :roles => :app do
- db_config = "#{deploy_to}/#{shared_dir}/conf/database.yml"
- run "cp #{db_config} #{release_path}/config/database.yml"
- end
- after "deploy:update_code", :copy_database_yml
- desc "Setup the deplyment environment for staging"
- task :staging do
- set :stage, 'staging'
- set :rails_env, stage
- end
- desc "Setup the deplyment environment for production"
- task :production do
- set :stage, 'production'
- set :rails_env, stage
- end
Add Comment
Please, Sign In to add comment