From 04640dbbf3098e061550b2d6e57c6771765d8371 Mon Sep 17 00:00:00 2001 From: ivanvr Date: Mon, 28 Nov 2011 19:10:31 -0600 Subject: [PATCH] Tweak configurable deploy.rb --- .gitignore | 1 + config/deploy.example.rb | 20 +++++++++++++------- config/deploy.rb | 73 ------------------------------------------------------------------------- 3 files changed, 14 insertions(+), 80 deletions(-) delete mode 100644 config/deploy.rb diff --git a/.gitignore b/.gitignore index 00c6798..6519419 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ log/*.log tmp/**/* tmp/* config/config.yml +config/deploy.rb config/deploy config/mongoid.yml config/newrelic.yml diff --git a/config/deploy.example.rb b/config/deploy.example.rb index 5f4592e..8a514a2 100644 --- a/config/deploy.example.rb +++ b/config/deploy.example.rb @@ -6,21 +6,27 @@ # `cap deploy` whenever you would like to deploy Errbit. Refer # to the Readme for more information. +config = YAML.load_file('config/config.yml')['deployment'] || {} + require 'bundler/capistrano' set :application, "errbit" -set :repository, "http://github.com/jdpace/errbit.git" +set :repository, config['repository'] || "http://github.com/errbit/errbit.git" -role :web, "errbit.example.com" -role :app, "errbit.example.com" -role :db, "errbit.example.com", :primary => true +role :web, config['hosts']['web'] || "errbit.example.com" +role :app, config['hosts']['app'] || "errbit.example.com" +role :db, config['hosts']['db'] || "errbit.example.com", :primary => true -set :user, :deploy +set :user, config['user'] || :deploy set :use_sudo, false -set :ssh_options, { :forward_agent => true } +if config.has_key?('ssh_key') + set :ssh_options, { :forward_agent => true, :keys => [ config['ssh_key'] ] } +else + set :ssh_options, { :forward_agent => true } +end default_run_options[:pty] = true -set :deploy_to, "/var/www/apps/#{application}" +set :deploy_to, config['deploy_to'] || "/var/www/apps/#{application}" set :deploy_via, :remote_cache set :copy_cache, true set :copy_exclude, [".git"] diff --git a/config/deploy.rb b/config/deploy.rb deleted file mode 100644 index 659fa3a..0000000 --- a/config/deploy.rb +++ /dev/null @@ -1,73 +0,0 @@ -# Deploy Config -# ============= -# -# Copy this file to config/deploy.rb and customize it as needed. -# Then run `cap deploy:setup` to set up your server and finally -# `cap deploy` whenever you would like to deploy Errbit. Refer -# to the Readme for more information. - -config = YAML.load_file('config/config.yml')['deployment'] - -require 'bundler/capistrano' - -set :application, "errbit" -set :repository, config['repository'] - -role :web, config['hosts']['web'] -role :app, config['hosts']['app'] -role :db, config['hosts']['db'], :primary => true - -set :user, config['user'] -set :use_sudo, false -# if config.has_key?('ssh_key') - set :ssh_options, { :forward_agent => true, :keys => [ config['ssh_key'] ] } -# else - # set :ssh_options, { :forward_agent => true } -# end -default_run_options[:pty] = true - -set :deploy_to, config['deploy_to'] -set :deploy_via, :remote_cache -set :copy_cache, true -set :copy_exclude, [".git"] -set :copy_compression, :bz2 - -set :scm, :git -set :scm_verbose, true -set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't determine current branch") } -set :branch, defer { current_branch } - -after 'deploy:update_code', 'errbit:symlink_configs' - -namespace :deploy do - task :start do ; end - task :stop do ; end - task :restart, :roles => :app, :except => { :no_release => true } do - run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" - end -end - -namespace :errbit do - task :setup_configs do - shared_configs = File.join(shared_path,'config') - run "mkdir -p #{shared_configs}" - run "if [ ! -f #{shared_configs}/config.yml ]; then cp #{latest_release}/config/config.example.yml #{shared_configs}/config.yml; fi" - run "if [ ! -f #{shared_configs}/mongoid.yml ]; then cp #{latest_release}/config/mongoid.example.yml #{shared_configs}/mongoid.yml; fi" - end - - task :symlink_configs do - errbit.setup_configs - shared_configs = File.join(shared_path,'config') - release_configs = File.join(release_path,'config') - run("ln -nfs #{shared_configs}/config.yml #{release_configs}/config.yml") - run("ln -nfs #{shared_configs}/mongoid.yml #{release_configs}/mongoid.yml") - end -end - -namespace :db do - desc "Create the indexes defined on your mongoid models" - task :create_mongoid_indexes do - run "cd #{current_path} && bundle exec rake db:mongoid:create_indexes" - end -end - -- libgit2 0.21.2