forked from rbCAS/CASinoApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.example.rb
73 lines (56 loc) · 2.18 KB
/
deploy.example.rb
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
73
require 'bundler/capistrano'
set :whenever_command, 'bundle exec whenever'
require 'whenever/capistrano'
config = YAML.load_file('config/deployment-config.yml') || {}
set :application, 'CASinoApp'
set :repository, config['repository']
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 }
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
set :ssh_options, { :forward_agent => true }
set :deploy_to, config['deploy_to']
set :deploy_via, :remote_cache
desc 'Deploy database.yml file'
task :deploy_database_yml, :roles => :app do
template = File.read('config/deploy/database.yml')
put template, "#{shared_path}/config/database.yml"
end
after 'deploy:setup', :deploy_database_yml
desc 'Deploy cas.yml file'
task :deploy_cas_yml, :roles => :app do
template = File.read('config/deploy/cas.yml')
put template, "#{shared_path}/config/cas.yml"
end
after 'deploy:setup', :deploy_cas_yml
after "deploy:restart", "deploy:cleanup"
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
before 'deploy:assets:symlink', 'casinoapp:symlink_configs'
namespace :casinoapp do
task :setup_config do
shared_config_path = File.join(shared_path,'config')
run "mkdir -p #{shared_config_path}"
run %Q{if [ ! -f #{shared_config_path}/secret_token.rb ]; then
cd #{current_release};
echo "CASinoApp::Application.config.secret_token = '$(bundle exec rake secret)'" > #{shared_config_path}/secret_token.rb;
fi}.compact
end
task :symlink_configs do
casinoapp.setup_config
shared_config_path = File.join(shared_path,'config')
release_config_path = File.join(release_path,'config')
run("ln -nfs #{shared_config_path}/cas.yml #{release_config_path}/cas.yml")
run("ln -nfs #{shared_config_path}/secret_token.rb #{release_config_path}/initializers/secret_token.rb")
end
end