dlss-capistrano 3.8.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +30 -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/sneakers_systemd.rake +44 -0
- data/lib/dlss/capistrano/tasks/ssh_check.rake +6 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de77b7bc3796b78fdbbc7b4900fb773bc31f98bf86713751311d62fa1a686c55
|
4
|
+
data.tar.gz: 8688c207edc6e7aa97008b7a9e209cfa19f391e463eac79cedd9a4d4ea352c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e66b1a045e9656bcf2f6c046a87cb1fad008cb0dd0f6044928738da5d1c780c256a238533fd0f05478caa948ef4fdfdf509ee11572f008b28f5a3db1dde8c2
|
7
|
+
data.tar.gz: 03de4eecdf5adca8277f84d4167e1f587ab758f38a75f8d11f5feac662d851fa9637ea812948c276347c00557f7c3a02c536fff34e5e51eca8fa2aeaebb5defc
|
data/README.md
CHANGED
@@ -35,16 +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
|
+
|
38
42
|
### Display Revision (and branches)
|
39
43
|
|
40
44
|
`cap ENV deployed_branch` displays the currently deployed revision (commit ID) and any branches containing the revision for each server in `ENV`.
|
41
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
|
+
|
42
67
|
### Sidekiq via systemd
|
43
68
|
|
44
69
|
`cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
|
45
70
|
|
46
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.
|
47
72
|
|
73
|
+
### Sneakers via systemd
|
74
|
+
|
75
|
+
`cap ENV sneakers_systemd:{stop,start,restart}`: stops, starts, restarts Sneakers via systemd.
|
76
|
+
|
77
|
+
|
48
78
|
#### Capistrano role
|
49
79
|
|
50
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.*:
|
@@ -80,7 +110,6 @@ dlss-capistrano makes the following assumptions about your Ruby project
|
|
80
110
|
- You do not have an .rvmrc checked into git (should be in your .gitignore)
|
81
111
|
- You will not use rvm gemsets on the server you deploy to
|
82
112
|
- Bundler will install specified gems into {your_project_home}/shared/bundle directory
|
83
|
-
- Will deploy from the master branch, unless you set :branch to another branch or tag
|
84
113
|
|
85
114
|
## Copyright
|
86
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,44 @@
|
|
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:stop'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Stop running workers gracefully'
|
25
|
+
task :stop do
|
26
|
+
on roles fetch(:sneakers_systemd_role) do
|
27
|
+
sudo :systemctl, 'stop', 'sneakers'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Start workers'
|
32
|
+
task :start do
|
33
|
+
on roles fetch(:sneakers_systemd_role) do
|
34
|
+
sudo :systemctl, 'start', 'sneakers'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Restart workers'
|
39
|
+
task :restart do
|
40
|
+
on roles fetch(:sneakers_systemd_role) do
|
41
|
+
sudo :systemctl, 'restart', 'sneakers', raise_on_non_zero_exit: false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.1
|
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,11 +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
|
90
92
|
- lib/dlss/capistrano/tasks/deployed_branch.rake
|
91
93
|
- lib/dlss/capistrano/tasks/sidekiq_systemd.rake
|
94
|
+
- lib/dlss/capistrano/tasks/sneakers_systemd.rake
|
92
95
|
- lib/dlss/capistrano/tasks/ssh.rake
|
96
|
+
- lib/dlss/capistrano/tasks/ssh_check.rake
|
93
97
|
- lib/lyberteam-capistrano-devel.rb
|
94
98
|
homepage:
|
95
99
|
licenses:
|
@@ -110,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
114
|
- !ruby/object:Gem::Version
|
111
115
|
version: 1.3.6
|
112
116
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.1.4
|
114
118
|
signing_key:
|
115
119
|
specification_version: 4
|
116
120
|
summary: Capistrano recipes for use in SUL/DLSS projects
|