Commit 04640dbbf3098e061550b2d6e57c6771765d8371

Authored by ivanvr
1 parent d0566313
Exists in master and in 1 other branch production

Tweak configurable deploy.rb

.gitignore
... ... @@ -4,6 +4,7 @@ log/*.log
4 4 tmp/**/*
5 5 tmp/*
6 6 config/config.yml
  7 +config/deploy.rb
7 8 config/deploy
8 9 config/mongoid.yml
9 10 config/newrelic.yml
... ...
config/deploy.example.rb
... ... @@ -6,21 +6,27 @@
6 6 # `cap deploy` whenever you would like to deploy Errbit. Refer
7 7 # to the Readme for more information.
8 8  
  9 +config = YAML.load_file('config/config.yml')['deployment'] || {}
  10 +
9 11 require 'bundler/capistrano'
10 12  
11 13 set :application, "errbit"
12   -set :repository, "http://github.com/jdpace/errbit.git"
  14 +set :repository, config['repository'] || "http://github.com/errbit/errbit.git"
13 15  
14   -role :web, "errbit.example.com"
15   -role :app, "errbit.example.com"
16   -role :db, "errbit.example.com", :primary => true
  16 +role :web, config['hosts']['web'] || "errbit.example.com"
  17 +role :app, config['hosts']['app'] || "errbit.example.com"
  18 +role :db, config['hosts']['db'] || "errbit.example.com", :primary => true
17 19  
18   -set :user, :deploy
  20 +set :user, config['user'] || :deploy
19 21 set :use_sudo, false
20   -set :ssh_options, { :forward_agent => true }
  22 +if config.has_key?('ssh_key')
  23 + set :ssh_options, { :forward_agent => true, :keys => [ config['ssh_key'] ] }
  24 +else
  25 + set :ssh_options, { :forward_agent => true }
  26 +end
21 27 default_run_options[:pty] = true
22 28  
23   -set :deploy_to, "/var/www/apps/#{application}"
  29 +set :deploy_to, config['deploy_to'] || "/var/www/apps/#{application}"
24 30 set :deploy_via, :remote_cache
25 31 set :copy_cache, true
26 32 set :copy_exclude, [".git"]
... ...
config/deploy.rb
... ... @@ -1,73 +0,0 @@
1   -# Deploy Config
2   -# =============
3   -#
4   -# Copy this file to config/deploy.rb and customize it as needed.
5   -# Then run `cap deploy:setup` to set up your server and finally
6   -# `cap deploy` whenever you would like to deploy Errbit. Refer
7   -# to the Readme for more information.
8   -
9   -config = YAML.load_file('config/config.yml')['deployment']
10   -
11   -require 'bundler/capistrano'
12   -
13   -set :application, "errbit"
14   -set :repository, config['repository']
15   -
16   -role :web, config['hosts']['web']
17   -role :app, config['hosts']['app']
18   -role :db, config['hosts']['db'], :primary => true
19   -
20   -set :user, config['user']
21   -set :use_sudo, false
22   -# if config.has_key?('ssh_key')
23   - set :ssh_options, { :forward_agent => true, :keys => [ config['ssh_key'] ] }
24   -# else
25   - # set :ssh_options, { :forward_agent => true }
26   -# end
27   -default_run_options[:pty] = true
28   -
29   -set :deploy_to, config['deploy_to']
30   -set :deploy_via, :remote_cache
31   -set :copy_cache, true
32   -set :copy_exclude, [".git"]
33   -set :copy_compression, :bz2
34   -
35   -set :scm, :git
36   -set :scm_verbose, true
37   -set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't determine current branch") }
38   -set :branch, defer { current_branch }
39   -
40   -after 'deploy:update_code', 'errbit:symlink_configs'
41   -
42   -namespace :deploy do
43   - task :start do ; end
44   - task :stop do ; end
45   - task :restart, :roles => :app, :except => { :no_release => true } do
46   - run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
47   - end
48   -end
49   -
50   -namespace :errbit do
51   - task :setup_configs do
52   - shared_configs = File.join(shared_path,'config')
53   - run "mkdir -p #{shared_configs}"
54   - run "if [ ! -f #{shared_configs}/config.yml ]; then cp #{latest_release}/config/config.example.yml #{shared_configs}/config.yml; fi"
55   - run "if [ ! -f #{shared_configs}/mongoid.yml ]; then cp #{latest_release}/config/mongoid.example.yml #{shared_configs}/mongoid.yml; fi"
56   - end
57   -
58   - task :symlink_configs do
59   - errbit.setup_configs
60   - shared_configs = File.join(shared_path,'config')
61   - release_configs = File.join(release_path,'config')
62   - run("ln -nfs #{shared_configs}/config.yml #{release_configs}/config.yml")
63   - run("ln -nfs #{shared_configs}/mongoid.yml #{release_configs}/mongoid.yml")
64   - end
65   -end
66   -
67   -namespace :db do
68   - desc "Create the indexes defined on your mongoid models"
69   - task :create_mongoid_indexes do
70   - run "cd #{current_path} && bundle exec rake db:mongoid:create_indexes"
71   - end
72   -end
73   -