dlss-capistrano 3.7.0 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -1
- data/dlss-capistrano.gemspec +1 -1
- data/lib/dlss/capistrano/resque_pool.rb +1 -0
- data/lib/dlss/capistrano/resque_pool/tasks/resque_pool.rake +60 -0
- data/lib/dlss/capistrano/tasks/deployed_branch.rake +10 -0
- data/lib/dlss/capistrano/tasks/sneakers_systemd.rake +52 -0
- data/lib/dlss/capistrano/tasks/ssh_check.rake +6 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80eb28bbf5c58cf57b561882ef7a7f3cffed327710fb733ac0a4450fa275fd15
|
4
|
+
data.tar.gz: a3ae9e2feb13dd590e599a786ed7cbe2e1453ffae78124b7026eef45c1ae53b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f13360fdbe742cf471edab521728b79a2f685fb4e98182875b951b29d65d42487cb0ccc79fd589afff5f5226d100774ff9438c25c5a724fe54ac38e6214bab8
|
7
|
+
data.tar.gz: 1eb046a6aca94b7d5e5ede77d06624d601dcb9548d4648bae559cb404fc4932e5d9564f0e600d352766e9a114362a0ff52632c9ffc478727efbc8ef6a9c81b89
|
data/README.md
CHANGED
@@ -35,12 +35,46 @@ Set this in `config/deploy.rb` to automate the symlink creation, and then use `X
|
|
35
35
|
|
36
36
|
`cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory
|
37
37
|
|
38
|
+
### SSH Connection Checking
|
39
|
+
|
40
|
+
`cap ENV ssh_check` establishes an SSH connection to all app servers running in `ENV` environment and prints environment information to confirm the connection was made. This is used by [sdr-deploy](https://github.com/sul-dlss-labs/sdr-deploy/) to check SSH connections can be made in bulk before proceeding with a mass deploy.
|
41
|
+
|
42
|
+
### Display Revision (and branches)
|
43
|
+
|
44
|
+
`cap ENV deployed_branch` displays the currently deployed revision (commit ID) and any branches containing the revision for each server in `ENV`.
|
45
|
+
|
46
|
+
### Resque-Pool hot swap (OPTIONAL)
|
47
|
+
|
48
|
+
The `dlss-capistrano` gem provides a set of tasks for managing `resque-pool` workers when deployed in `hot_swap` mode. (If you are using `resque-pool` without `hot_swap`, we recommend continuing to use the `capistrano-resque-pool` gem instead of what `dlss-capistrano` provides.) The tasks are:
|
49
|
+
|
50
|
+
```shell
|
51
|
+
$ cap ENV resque:pool:hot_swap # this gracefully replaces the current pool with a new pool
|
52
|
+
$ cap ENV resque:pool:stop # this gracefully stops the current pool
|
53
|
+
```
|
54
|
+
|
55
|
+
By default, these tasks are not provided; instead, they must be explicitly enabled via adding a new `require` statement to the application's `Capfile`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'dlss/capistrano/resque_pool'
|
59
|
+
```
|
60
|
+
|
61
|
+
This is the hook provided if you opt in:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
after 'deploy:publishing', 'resque:pool:hot_swap'
|
65
|
+
```
|
66
|
+
|
38
67
|
### Sidekiq via systemd
|
39
68
|
|
40
69
|
`cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
|
41
70
|
|
42
71
|
These tasks are intended to replace those provided by `capistrano-sidekiq` gem, which has assumptions about systemd that do not apply to our deployed environments.
|
43
72
|
|
73
|
+
### Sneakers via systemd
|
74
|
+
|
75
|
+
`cap ENV sneakers_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sneakers via systemd.
|
76
|
+
|
77
|
+
|
44
78
|
#### Capistrano role
|
45
79
|
|
46
80
|
The sidekiq_systemd tasks assume a Capistrano role of `:app`. If your application uses a different Capistrano role for hosts that run Sidekiq workers, you can configure this in `config/deploy.rb`, *e.g.*:
|
@@ -76,7 +110,6 @@ dlss-capistrano makes the following assumptions about your Ruby project
|
|
76
110
|
- You do not have an .rvmrc checked into git (should be in your .gitignore)
|
77
111
|
- You will not use rvm gemsets on the server you deploy to
|
78
112
|
- Bundler will install specified gems into {your_project_home}/shared/bundle directory
|
79
|
-
- Will deploy from the master branch, unless you set :branch to another branch or tag
|
80
113
|
|
81
114
|
## Copyright
|
82
115
|
|
data/dlss-capistrano.gemspec
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
import "#{__dir__}/resque_pool/tasks/resque_pool.rake"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# These tasks are a drop-in replacement for capistrano-resque-pool when using
|
4
|
+
# hot-swappable pools. We replace these tasks because the upstream ones assume a
|
5
|
+
# pidfile is present, which is not the case with hot-swappable pools.
|
6
|
+
|
7
|
+
namespace :load do
|
8
|
+
task :defaults do
|
9
|
+
# Same capistrano variable used by capistrano-resque-pool for compatibility
|
10
|
+
set :resque_server_roles, fetch(:resque_server_roles, [:app])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Integrate hook into Capistrano
|
15
|
+
namespace :deploy do
|
16
|
+
before :starting, :add_resque_pool_hotswap_hook do
|
17
|
+
invoke 'resque:pool:add_hook'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :resque do
|
22
|
+
namespace :pool do
|
23
|
+
# Lifted from capistrano-resque-pool
|
24
|
+
def rails_env
|
25
|
+
fetch(:resque_rails_env) ||
|
26
|
+
fetch(:rails_env) || # capistrano-rails doesn't automatically set this (yet),
|
27
|
+
fetch(:stage) # so we need to fall back to the stage.
|
28
|
+
end
|
29
|
+
|
30
|
+
# NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
|
31
|
+
task :add_hook do
|
32
|
+
after 'deploy:publishing', 'resque:pool:hot_swap'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Swap in a new pool, then shut down the old pool'
|
36
|
+
task :hot_swap do
|
37
|
+
on roles(fetch(:resque_server_roles)) do
|
38
|
+
within current_path do
|
39
|
+
execute :bundle, :exec, 'resque-pool', "--daemon --hot-swap --environment #{rails_env}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Gracefully shut down current pool'
|
45
|
+
task :stop do
|
46
|
+
on roles(fetch(:resque_server_roles)) do
|
47
|
+
# This will usually return a single pid, but if you do multiple quick
|
48
|
+
# deployments, you may pick up multiple pids here, in which case we only
|
49
|
+
# kill the oldest one
|
50
|
+
pid = capture(:pgrep, '-f resque-pool-master').split.first
|
51
|
+
|
52
|
+
if test "kill -0 #{pid} > /dev/null 2>&1"
|
53
|
+
execute :kill, "-s QUIT #{pid}"
|
54
|
+
else
|
55
|
+
warn "Process #{pid} is not running"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
desc 'display the deployed branch and commit'
|
2
|
+
task :deployed_branch do
|
3
|
+
on roles(:app) do |host|
|
4
|
+
within current_path do
|
5
|
+
revision = capture :cat, 'REVISION'
|
6
|
+
branches = `git branch -r --contains #{revision}`.strip
|
7
|
+
info "#{host}: #{revision} (#{branches})"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Capistrano plugin hook to set default values
|
2
|
+
namespace :load do
|
3
|
+
task :defaults do
|
4
|
+
set :sneakers_systemd_role, fetch(:sneakers_systemd_role, :app)
|
5
|
+
set :sneakers_systemd_use_hooks, fetch(:sneakers_systemd_use_hooks, false)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Integrate sneakers hooks into Capistrano
|
10
|
+
namespace :deploy do
|
11
|
+
before :starting, :add_sneakers_systemd_hooks do
|
12
|
+
invoke 'sneakers_systemd:add_hooks' if fetch(:sneakers_systemd_use_hooks)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :sneakers_systemd do
|
17
|
+
# NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
|
18
|
+
task :add_hooks do
|
19
|
+
after 'deploy:failed', 'sneakers_systemd:restart'
|
20
|
+
after 'deploy:published', 'sneakers_systemd:start'
|
21
|
+
after 'deploy:starting', 'sneakers_systemd:quiet'
|
22
|
+
after 'deploy:updated', 'sneakers_systemd:stop'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Stop workers from picking up new jobs'
|
26
|
+
task :quiet do
|
27
|
+
on roles fetch(:sneakers_systemd_role) do
|
28
|
+
sudo :systemctl, 'reload', 'sneakers', raise_on_non_zero_exit: false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Stop running workers gracefully'
|
33
|
+
task :stop do
|
34
|
+
on roles fetch(:sneakers_systemd_role) do
|
35
|
+
sudo :systemctl, 'stop', 'sneakers'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Start workers'
|
40
|
+
task :start do
|
41
|
+
on roles fetch(:sneakers_systemd_role) do
|
42
|
+
sudo :systemctl, 'start', 'sneakers'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Restart workers'
|
47
|
+
task :restart do
|
48
|
+
on roles fetch(:sneakers_systemd_role) do
|
49
|
+
sudo :systemctl, 'restart', 'sneakers', raise_on_non_zero_exit: false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dlss-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -85,10 +85,15 @@ files:
|
|
85
85
|
- dlss-capistrano.gemspec
|
86
86
|
- lib/dlss.rb
|
87
87
|
- lib/dlss/capistrano.rb
|
88
|
+
- lib/dlss/capistrano/resque_pool.rb
|
89
|
+
- lib/dlss/capistrano/resque_pool/tasks/resque_pool.rake
|
88
90
|
- lib/dlss/capistrano/tasks/bundle_config.rake
|
89
91
|
- lib/dlss/capistrano/tasks/bundled_sidekiq.rake
|
92
|
+
- lib/dlss/capistrano/tasks/deployed_branch.rake
|
90
93
|
- lib/dlss/capistrano/tasks/sidekiq_systemd.rake
|
94
|
+
- lib/dlss/capistrano/tasks/sneakers_systemd.rake
|
91
95
|
- lib/dlss/capistrano/tasks/ssh.rake
|
96
|
+
- lib/dlss/capistrano/tasks/ssh_check.rake
|
92
97
|
- lib/lyberteam-capistrano-devel.rb
|
93
98
|
homepage:
|
94
99
|
licenses:
|
@@ -109,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
114
|
- !ruby/object:Gem::Version
|
110
115
|
version: 1.3.6
|
111
116
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.1.4
|
113
118
|
signing_key:
|
114
119
|
specification_version: 4
|
115
120
|
summary: Capistrano recipes for use in SUL/DLSS projects
|