public
Description: Vault
Homepage: http://peervoice.com/software/vault
Clone URL: git://github.com/ddollar/vault.git
Search Repo:
ddollar (author)
Thu Apr 17 20:11:10 -0700 2008
commit  abc2f77bd7116f018121044330ef61b684ca5bd0
tree    f8d8f35db044ba0714cb0429e1b878837e18dfc3
parent  26d4f128ece029090f2e355150ba6493870b2f48
vault / config / deploy.rb
100644 72 lines (57 sloc) 2.404 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# deployment servers
role :app, "delta.peervoice.com"
role :web, "delta.peervoice.com"
role :db, "delta.peervoice.com", :primary => true
 
# application name in source control
set :application_scm, :generic
 
# dynamic targets
set :target, ENV["TARGET"] || :default
load "config/targets/#{target}"
 
# basic deployment info, should not have to change
set :scm, :git
set :repository, "git@peervoice.com:rails/#{application_scm}.git"
set :deploy_to, "/srv/app/#{application}"
set :user, "app"
set :ssh_options, { :forward_agent => true }
set :conf_dir, "/srv/conf/apps/#{application}"
 
# mongrel_cluster integration
require 'mongrel_cluster/recipes'
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
 
# custom deploy tasks
namespace :peervoice do
 
  namespace :configure do
  
    desc "copy app-specific configuration files into place"
    task :application do
      run %{if [ -d #{conf_dir} ]; then cp -R #{conf_dir}/* #{current_path}/config/; fi}
      run %{cd #{release_path} && rake peervoice:configure:target}
    end
    
    task :sqlite do
      run %{mkdir -p #{shared_path}/db}
      run %{ln -nfs #{shared_path}/db/production.sqlite3 #{release_path}/db/production.sqlite3}
    end
  
  end
    
  namespace :mongrel do
 
    desc "set up god for these mongrels"
    task :god do
      god_conf = "/srv/conf/god/rails/#{application}.god"
      sudo %{/srv/util/mongrel-god/mongrel-god.rb "#{application}" "#{mongrel_conf}" "#{god_conf}"}
      sudo %{god load #{god_conf}}
    end
    
    desc "get an available port for this mongrel"
    task :port do
      run %{/srv/util/mongrel-port/mongrel-port.rb "#{application}" "#{mongrel_conf}.deploy" > "#{mongrel_conf}"}
    end
    
    desc "register this mongrel with nginx"
    task :nginx do
      sudo %{ln -sf "#{mongrel_conf}" "/etc/mongrel/#{application}.yml"}
      sudo %{ln -sf "#{mongrel_conf}" "/srv/conf/mongrel/#{application}.yml"}
      sudo %{/srv/util/mongrel-nginx/mongrel-nginx.rb "#{application}" "#{mongrel_conf}" "/srv/conf/sites/#{application}.site"}
      sudo %{/etc/init.d/nginx restart}
    end
 
  end
end
 
after 'deploy:update_code', 'peervoice:configure:application'
after 'deploy:update_code', 'peervoice:configure:sqlite'
after 'deploy:symlink', 'peervoice:mongrel:port'
after 'deploy:symlink', 'peervoice:mongrel:god'
after 'deploy:symlink', 'peervoice:mongrel:nginx'