|
1 |
| -set :author, "ontoportal-lirmm" |
2 |
| -set :application, "ontologies_api" |
3 |
| -set :repo_url, "https://github.com/#{fetch(:author)}/#{fetch(:application)}.git" |
| 1 | +# config valid only for Capistrano 3 |
4 | 2 |
|
5 | 3 | APP_PATH = '/srv/ontoportal'
|
6 | 4 |
|
|
13 | 11 | # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
|
14 | 12 |
|
15 | 13 | # Default deploy_to directory is /var/www/my_app
|
16 |
| -set :deploy_to, "/srv/ontoportal/#{fetch(:application)}" |
| 14 | +set :deploy_to, "#{APP_PATH}/#{fetch(:application)}" |
17 | 15 |
|
18 | 16 | # Default value for :scm is :git
|
19 | 17 | # set :scm, :git
|
|
22 | 20 | # set :format, :pretty
|
23 | 21 |
|
24 | 22 | # Default value for :log_level is :debug
|
25 |
| -set :log_level, :error |
| 23 | +# set :log_level, :debug |
26 | 24 |
|
27 | 25 | # Default value for :pty is false
|
28 | 26 | # set :pty, true
|
|
47 | 45 | # required for restarting unicorn with sudo
|
48 | 46 | set :pty, true
|
49 | 47 | # Default value for default_env is {}
|
50 |
| -# set :default_env, { path: "/opt/ruby/bin:$PATH" } |
| 48 | +set :default_env, { |
| 49 | +} |
51 | 50 |
|
52 | 51 | # Default value for keep_releases is 5
|
53 | 52 | set :keep_releases, 5
|
54 |
| -set :config_folder_path, "#{fetch(:application)}/#{fetch(:stage)}" |
55 |
| - |
56 |
| -# If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb: |
57 |
| - |
58 |
| -SSH_JUMPHOST = ENV.include?('SSH_JUMPHOST') ? ENV['SSH_JUMPHOST'] : 'jumpbox.hostname.com' |
59 |
| -SSH_JUMPHOST_USER = ENV.include?('SSH_JUMPHOST_USER') ? ENV['SSH_JUMPHOST_USER'] : 'username' |
60 |
| - |
61 |
| -JUMPBOX_PROXY = "#{SSH_JUMPHOST_USER}@#{SSH_JUMPHOST}" |
62 |
| -set :ssh_options, { |
63 |
| - user: 'ontoportal', |
64 |
| - forward_agent: 'true', |
65 |
| - keys: %w(config/deploy_id_rsa), |
66 |
| - auth_methods: %w(publickey), |
67 |
| - # use ssh proxy if API servers are on a private network |
68 |
| - proxy: Net::SSH::Proxy::Command.new("ssh #{JUMPBOX_PROXY} -W %h:%p") |
69 |
| -} |
70 |
| - |
71 |
| -# private git repo for configuraiton |
72 |
| -PRIVATE_CONFIG_REPO = ENV.include?('PRIVATE_CONFIG_REPO') ? ENV['PRIVATE_CONFIG_REPO'] : 'https://[email protected]/your_organization/ontoportal-configs.git' |
73 |
| -desc "Check if agent forwarding is working" |
74 |
| -task :forwarding do |
75 |
| - on roles(:all) do |h| |
76 |
| - if test("env | grep SSH_AUTH_SOCK") |
77 |
| - info "Agent forwarding is up to #{h}" |
78 |
| - else |
79 |
| - error "Agent forwarding is NOT up to #{h}" |
80 |
| - end |
81 |
| - end |
82 |
| -end |
83 | 53 |
|
84 | 54 | # inspired by http://nathaniel.talbott.ws/blog/2013/03/14/post-deploy-smoke-tests/
|
85 | 55 | desc 'Run smoke test'
|
|
107 | 77 | end
|
108 | 78 | end
|
109 | 79 |
|
| 80 | + |
110 | 81 | namespace :deploy do
|
111 | 82 |
|
112 | 83 | desc 'Incorporate the private repository content'
|
113 | 84 | # Get cofiguration from repo if PRIVATE_CONFIG_REPO env var is set
|
114 | 85 | # or get config from local directory if LOCAL_CONFIG_PATH env var is set
|
115 | 86 | task :get_config do
|
116 | 87 | if defined?(PRIVATE_CONFIG_REPO)
|
117 |
| - TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}".freeze |
| 88 | + TMP_CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}" |
118 | 89 | on roles(:app) do
|
119 | 90 | execute "git clone -q #{PRIVATE_CONFIG_REPO} #{TMP_CONFIG_PATH}"
|
120 |
| - execute "rsync -av #{TMP_CONFIG_PATH}/#{fetch(:config_folder_path)}/ #{release_path}/" |
| 91 | + execute "rsync -av #{TMP_CONFIG_PATH}/#{fetch(:application)}/ #{release_path}/" |
121 | 92 | execute "rm -rf #{TMP_CONFIG_PATH}"
|
122 | 93 | end
|
123 | 94 | elsif defined?(LOCAL_CONFIG_PATH)
|
|
130 | 101 | desc 'Restart application'
|
131 | 102 | task :restart do
|
132 | 103 | on roles(:app), in: :sequence, wait: 5 do
|
133 |
| - # Your restart mechanism here, for example: |
134 |
| - # execute :touch, release_path.join('tmp/restart.txt') |
135 |
| - execute 'sudo systemctl restart unicorn' |
136 |
| - execute 'sleep 5' |
| 104 | + # Your restart mechanism here, for example: |
| 105 | + # execute :touch, release_path.join('tmp/restart.txt') |
| 106 | + execute 'sudo systemctl restart unicorn' |
| 107 | + execute 'sleep 5' |
137 | 108 | end
|
138 | 109 | end
|
139 | 110 |
|
|
0 commit comments