dlss-capistrano 3.9.0 → 3.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b7211b899ad56e248f23fc755708985d824d75c5f5be60f9df209e7aa530889
4
- data.tar.gz: de4c047a15d8388a9b03a291db95923384f6a3e63468302af117b3a96013ffd8
3
+ metadata.gz: e70dce4334fb19dd733691feeb6767a15ad60ec0b23cdd798db3b95eac0cbb3c
4
+ data.tar.gz: 2ec578117cf92d26845b752285b7f4f469978873584d8f2abfbc18dd66c49aaf
5
5
  SHA512:
6
- metadata.gz: 75f59b62a79644b31a359530daabae1cf65b8d5d87542c7612081f8866f01df16c3ec67751dac1e8bcd8484f871c921a8a0c4f8845d355dbb934896e61701e23
7
- data.tar.gz: '05957df37d899b68b350a776bf2fc70baf1a70492d35145577857e67fd0c02769b938b8a91773dc2d0846f8e30c6d01526e6b3372c1b4d52939b6238922700dc'
6
+ metadata.gz: 5aaf6ce12fd37b5586d8302116e2db5d94fb83076c8860ca203573ae93b414fc304892e45a4e5b2368bf68be260dc5c01b61d02319b63c7127c313cdb07821e6
7
+ data.tar.gz: c5f48c6365a083f290814c3063d3c65cd7ae49a48d3b303c4615758cd7df69dd7a6acc858ba6e47922f7a3caf8d81d046e2a6be7ecd09dfcff97b2eb97fa44a2
data/README.md CHANGED
@@ -43,6 +43,21 @@ Set this in `config/deploy.rb` to automate the symlink creation, and then use `X
43
43
 
44
44
  `cap ENV deployed_branch` displays the currently deployed revision (commit ID) and any branches containing the revision for each server in `ENV`.
45
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
+
46
61
  ### Sidekiq via systemd
47
62
 
48
63
  `cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
@@ -4,7 +4,7 @@ $:.unshift lib unless $:.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "dlss-capistrano"
7
- s.version = "3.9.0"
7
+ s.version = "3.10.0"
8
8
 
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Chris Beer", 'Mike Giarlo']
@@ -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:restart', '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
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.9.0
4
+ version: 3.10.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: 2020-06-22 00:00:00.000000000 Z
12
+ date: 2020-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -85,6 +85,8 @@ 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
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  - !ruby/object:Gem::Version
112
114
  version: 1.3.6
113
115
  requirements: []
114
- rubygems_version: 3.0.3
116
+ rubygems_version: 3.1.2
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: Capistrano recipes for use in SUL/DLSS projects