dlss-capistrano 3.6.0 → 3.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +12 -0
- data/README.md +40 -0
- data/dlss-capistrano.gemspec +1 -1
- data/lib/dlss/capistrano.rb +1 -3
- 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/bundled_sidekiq.rake +31 -0
- data/lib/dlss/capistrano/tasks/deployed_branch.rake +10 -0
- data/lib/dlss/capistrano/tasks/ssh_check.rake +6 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59f3e0a3a28fd4c039e6e2a861b16603911fe806ad71ca1aee18ffedb6e17ef9
|
4
|
+
data.tar.gz: c272545718a09a47b2cc2cd523edc55a6cd43c6b71453d390a14da1464d756d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cbb9b707d0ff42c95c15e97f08a70bfd02a19cdc7fda35ca112571c907e911e43a1451a8ca3cccebe902db757fa5f4a6f31fc86fd63ef5976cf8047a525021e
|
7
|
+
data.tar.gz: a9b908df522ad9696ca5b99b9235c77016fc3eaf9c7665fba277c5b3f48bb4ccf964c9c7c696339cbd204b99245587713e75fc8af24913a5c72d9732de14408e
|
data/README.md
CHANGED
@@ -20,10 +20,50 @@ set :bundler2_config_path, '/tmp' # set to '#{shared_path}/bundle' by default
|
|
20
20
|
|
21
21
|
Note that only `bundler2_config_use_hook` **must** be set in order to use this functionality.
|
22
22
|
|
23
|
+
### Sidekiq symlink
|
24
|
+
|
25
|
+
Every time the version of Sidekiq or Ruby changes, a corresponding Puppet PR must be made in order to update the XSendFilePath that allows Apache to access the bundled Sidekiq gem's assets. dlss-capistrano provides a hook to create a symlink to the bundled Sidekiq to avoid having to do this:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
set :bundled_sidekiq_symlink, true # false is the default value
|
29
|
+
set :bundled_sidekiq_roles, [:app] # this is the default value
|
30
|
+
```
|
31
|
+
|
32
|
+
Set this in `config/deploy.rb` to automate the symlink creation, and then use `XSendFilePath /path/to/my/app/shared/bundled_sidekiq/web/assets` in Apache configuration (in Puppet).
|
33
|
+
|
23
34
|
### SSH
|
24
35
|
|
25
36
|
`cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory
|
26
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
|
+
|
27
67
|
### Sidekiq via systemd
|
28
68
|
|
29
69
|
`cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
|
data/dlss-capistrano.gemspec
CHANGED
data/lib/dlss/capistrano.rb
CHANGED
@@ -2,6 +2,4 @@ require 'capistrano/one_time_key'
|
|
2
2
|
require 'capistrano/bundle_audit'
|
3
3
|
require 'capistrano/shared_configs'
|
4
4
|
|
5
|
-
|
6
|
-
load File.expand_path('../capistrano/tasks/sidekiq_systemd.rake', __FILE__)
|
7
|
-
load File.expand_path('../capistrano/tasks/ssh.rake', __FILE__)
|
5
|
+
Dir.glob("#{__dir__}/capistrano/tasks/*.rake").each { |r| import r }
|
@@ -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,31 @@
|
|
1
|
+
# Capistrano plugin hook to set default values
|
2
|
+
namespace :load do
|
3
|
+
task :defaults do
|
4
|
+
set :bundled_sidekiq_symlink, fetch(:bundled_sidekiq_symlink, false)
|
5
|
+
set :bundled_sidekiq_roles, fetch(:bundled_sidekiq_roles, [:app])
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Integrate sidekiq-bundle hook into Capistrano
|
10
|
+
namespace :deploy do
|
11
|
+
before :starting, :add_bundled_sidekiq_hook do
|
12
|
+
invoke 'bundled_sidekiq:add_hook' if fetch(:bundled_sidekiq_symlink)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :bundled_sidekiq do
|
17
|
+
# NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
|
18
|
+
task :add_hook do
|
19
|
+
after 'bundler:install', 'bundled_sidekiq:symlink'
|
20
|
+
end
|
21
|
+
|
22
|
+
# NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
|
23
|
+
task :symlink do
|
24
|
+
on roles fetch(:bundled_sidekiq_roles) do
|
25
|
+
within release_path do
|
26
|
+
bundled_sidekiq_path = capture(:bundle, :info, '--path', :sidekiq)
|
27
|
+
execute(:ln, '-sf', bundled_sidekiq_path, "#{shared_path}/bundled_sidekiq")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
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
|
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.10.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: 2020-
|
12
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -76,6 +76,7 @@ executables: []
|
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
|
+
- ".github/pull_request_template.md"
|
79
80
|
- ".gitignore"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE
|
@@ -84,9 +85,14 @@ files:
|
|
84
85
|
- dlss-capistrano.gemspec
|
85
86
|
- lib/dlss.rb
|
86
87
|
- lib/dlss/capistrano.rb
|
88
|
+
- lib/dlss/capistrano/resque_pool.rb
|
89
|
+
- lib/dlss/capistrano/resque_pool/tasks/resque_pool.rake
|
87
90
|
- lib/dlss/capistrano/tasks/bundle_config.rake
|
91
|
+
- lib/dlss/capistrano/tasks/bundled_sidekiq.rake
|
92
|
+
- lib/dlss/capistrano/tasks/deployed_branch.rake
|
88
93
|
- lib/dlss/capistrano/tasks/sidekiq_systemd.rake
|
89
94
|
- lib/dlss/capistrano/tasks/ssh.rake
|
95
|
+
- lib/dlss/capistrano/tasks/ssh_check.rake
|
90
96
|
- lib/lyberteam-capistrano-devel.rb
|
91
97
|
homepage:
|
92
98
|
licenses:
|
@@ -107,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
113
|
- !ruby/object:Gem::Version
|
108
114
|
version: 1.3.6
|
109
115
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.1.2
|
111
117
|
signing_key:
|
112
118
|
specification_version: 4
|
113
119
|
summary: Capistrano recipes for use in SUL/DLSS projects
|