dlss-capistrano 3.11.1 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de77b7bc3796b78fdbbc7b4900fb773bc31f98bf86713751311d62fa1a686c55
4
- data.tar.gz: 8688c207edc6e7aa97008b7a9e209cfa19f391e463eac79cedd9a4d4ea352c09
3
+ metadata.gz: 7c83f228efbada9563b37dee41ba9d92c9c0739be6ae0852e9141fd8bdfa27d8
4
+ data.tar.gz: b32eb019a8ff21b5e492a91c8a59ff133aed7f07b0143e6c49953c794c5b3ed6
5
5
  SHA512:
6
- metadata.gz: c8e66b1a045e9656bcf2f6c046a87cb1fad008cb0dd0f6044928738da5d1c780c256a238533fd0f05478caa948ef4fdfdf509ee11572f008b28f5a3db1dde8c2
7
- data.tar.gz: 03de4eecdf5adca8277f84d4167e1f587ab758f38a75f8d11f5feac662d851fa9637ea812948c276347c00557f7c3a02c536fff34e5e51eca8fa2aeaebb5defc
6
+ metadata.gz: b09739793af365242f7e7295fded043596973d12ae22096fd526411a7843ed495d93d43ea77a2b8211c0bf7d4529ad3005162e222302b0d7f17ede5a48f857a8
7
+ data.tar.gz: 39394b595c334c1ba591bdd8bcab7053a951281261e312703feb00efbf4a9e327a1c935f376bf9eaeeb35e8d98a305a0e97713dc39aa3ee1ab89143e671ff049
data/README.md CHANGED
@@ -6,20 +6,21 @@ This gem provides Capistrano deployment tasks used by Stanford Libraries' Digita
6
6
 
7
7
  ## Included Tasks
8
8
 
9
- ### Bundle 2-style Configuration
9
+ ### Remote Execution
10
10
 
11
- To override the capistrano-bundler gem and use Bundler 2-style configuration without using deprecated arguments, you can set the following settings in `config/deploy.rb`:
11
+ Sometimes you want to execute a command on all boxes in a given environment, and dlss-capistrano's got your back:
12
12
 
13
- ```ruby
14
- set :bundler2_config_use_hook, true # this is how to opt-in to bundler 2-style config. it's false by default
15
- set :bundler2_config_roles, [:app] # feel free to add roles to this array if you need them
16
- set :bundler2_config_deployment, true # this is true by default
17
- set :bundler2_config_without, 'production' # exclude development, and test bundle groups by default
18
- set :bundler2_config_path, '/tmp' # set to '#{shared_path}/bundle' by default
13
+ ```shell
14
+ $ cap qa remote_execute["ps -ef | grep rolling | grep -v grep"]
15
+ 00:00 remote_execute
16
+ ps -ef | grep rolling | grep -v grep
17
+ ps -ef | grep rolling | grep -v grep
18
+ dor-indexing-app-qa-a.stanford.edu:
19
+ dor_ind+ 9159 1 20 Feb18 ? 14:15:03 rolling index
20
+ dor-indexing-app-qa-b.stanford.edu:
21
+ dor_ind+ 29689 1 20 Feb18 ? 14:24:53 rolling index
19
22
  ```
20
23
 
21
- Note that only `bundler2_config_use_hook` **must** be set in order to use this functionality.
22
-
23
24
  ### Sidekiq symlink
24
25
 
25
26
  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:
@@ -31,6 +32,19 @@ set :bundled_sidekiq_roles, [:app] # this is the default value
31
32
 
32
33
  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
34
 
35
+ ### Status checking
36
+
37
+ **NOTE**: Requires that `curl` is installed on each server host the check is run on.
38
+
39
+ Use `cap ENV check_status` to hit the (*e.g.*, [okcomputer](https://github.com/sportngin/okcomputer)-based) status endpoint of your application. This is especially valuable with hosts that cannot be directly checked due to firewall rules.
40
+
41
+ By default, these checks run against all nodes with the `:web` role and hit the `/status/all` endpoint. These can be configured in `config/deploy.rb` (or `config/deploy/{ENV}.rb` if you need environment-specific variation):
42
+
43
+ ```ruby
44
+ set :check_status_roles, [:my_status_check_web_role]
45
+ set :check_status_path, '/my/status/check/endpoint'
46
+ ```
47
+
34
48
  ### SSH
35
49
 
36
50
  `cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory
@@ -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.11.1'
7
+ s.version = '4.1.1'
8
8
 
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Chris Beer", 'Mike Giarlo']
@@ -21,7 +21,7 @@ namespace :bundled_sidekiq do
21
21
 
22
22
  # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
23
23
  task :symlink do
24
- on roles fetch(:bundled_sidekiq_roles) do
24
+ on roles(fetch(:bundled_sidekiq_roles)) do
25
25
  within release_path do
26
26
  bundled_sidekiq_path = capture(:bundle, :info, '--path', :sidekiq)
27
27
  execute(:ln, '-sf', bundled_sidekiq_path, "#{shared_path}/bundled_sidekiq")
@@ -0,0 +1,23 @@
1
+ # Capistrano plugin hook to set default values
2
+ namespace :load do
3
+ task :defaults do
4
+ set :check_status_roles, fetch(:check_status_roles, [:web])
5
+ set :check_status_path, fetch(:check_status_path, '/status/all')
6
+ end
7
+ end
8
+
9
+ desc 'Run status checks'
10
+ task :check_status do
11
+ on roles(fetch(:check_status_roles)), in: :sequence do |host|
12
+ status_url = "https://#{host}#{fetch(:check_status_path)}"
13
+
14
+ info "Checking status at #{status_url}"
15
+ status_body = capture("curl #{status_url}")
16
+
17
+ if status_body.match?(/FAILED/)
18
+ error status_body.lines.grep(/FAILED/).join
19
+ else
20
+ info SSHKit::Color.new($stdout).colorize('All checks passed!', :green)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ desc "execute command on all servers"
2
+ task :remote_execute, :command do |_task, args|
3
+ raise ArgumentError, 'remote_execute task requires an argument' unless args[:command]
4
+
5
+ on roles(:all) do |host|
6
+ info args[:command] if fetch(:log_level) == :debug
7
+ info "#{host}:\n#{capture(args[:command])}"
8
+ end
9
+ end
@@ -24,28 +24,28 @@ namespace :sidekiq_systemd do
24
24
 
25
25
  desc 'Stop workers from picking up new jobs'
26
26
  task :quiet do
27
- on roles fetch(:sidekiq_systemd_role) do
27
+ on roles(fetch(:sidekiq_systemd_role)) do
28
28
  sudo :systemctl, 'reload', 'sidekiq-*', raise_on_non_zero_exit: false
29
29
  end
30
30
  end
31
31
 
32
32
  desc 'Stop running workers gracefully'
33
33
  task :stop do
34
- on roles fetch(:sidekiq_systemd_role) do
34
+ on roles(fetch(:sidekiq_systemd_role)) do
35
35
  sudo :systemctl, 'stop', 'sidekiq-*'
36
36
  end
37
37
  end
38
38
 
39
39
  desc 'Start workers'
40
40
  task :start do
41
- on roles fetch(:sidekiq_systemd_role) do
41
+ on roles(fetch(:sidekiq_systemd_role)) do
42
42
  sudo :systemctl, 'start', 'sidekiq-*', '--all'
43
43
  end
44
44
  end
45
45
 
46
46
  desc 'Restart workers'
47
47
  task :restart do
48
- on roles fetch(:sidekiq_systemd_role) do
48
+ on roles(fetch(:sidekiq_systemd_role)) do
49
49
  sudo :systemctl, 'restart', 'sidekiq-*', raise_on_non_zero_exit: false
50
50
  end
51
51
  end
@@ -23,21 +23,21 @@ namespace :sneakers_systemd do
23
23
 
24
24
  desc 'Stop running workers gracefully'
25
25
  task :stop do
26
- on roles fetch(:sneakers_systemd_role) do
26
+ on roles(fetch(:sneakers_systemd_role)) do
27
27
  sudo :systemctl, 'stop', 'sneakers'
28
28
  end
29
29
  end
30
30
 
31
31
  desc 'Start workers'
32
32
  task :start do
33
- on roles fetch(:sneakers_systemd_role) do
33
+ on roles(fetch(:sneakers_systemd_role)) do
34
34
  sudo :systemctl, 'start', 'sneakers'
35
35
  end
36
36
  end
37
37
 
38
38
  desc 'Restart workers'
39
39
  task :restart do
40
- on roles fetch(:sneakers_systemd_role) do
40
+ on roles(fetch(:sneakers_systemd_role)) do
41
41
  sudo :systemctl, 'restart', 'sneakers', raise_on_non_zero_exit: false
42
42
  end
43
43
  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.11.1
4
+ version: 4.1.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: 2021-02-26 00:00:00.000000000 Z
12
+ date: 2022-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -87,9 +87,10 @@ files:
87
87
  - lib/dlss/capistrano.rb
88
88
  - lib/dlss/capistrano/resque_pool.rb
89
89
  - lib/dlss/capistrano/resque_pool/tasks/resque_pool.rake
90
- - lib/dlss/capistrano/tasks/bundle_config.rake
91
90
  - lib/dlss/capistrano/tasks/bundled_sidekiq.rake
91
+ - lib/dlss/capistrano/tasks/check_status.rake
92
92
  - lib/dlss/capistrano/tasks/deployed_branch.rake
93
+ - lib/dlss/capistrano/tasks/remote_execute.rake
93
94
  - lib/dlss/capistrano/tasks/sidekiq_systemd.rake
94
95
  - lib/dlss/capistrano/tasks/sneakers_systemd.rake
95
96
  - lib/dlss/capistrano/tasks/ssh.rake
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: 1.3.6
116
117
  requirements: []
117
- rubygems_version: 3.1.4
118
+ rubygems_version: 3.2.32
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: Capistrano recipes for use in SUL/DLSS projects
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # These tasks exist because capistrano-bundler does not yet have a built-in
4
- # mechanism for configuring bundler 2 without deprecation warnings. We can dump
5
- # this if/when https://github.com/capistrano/bundler/issues/115 is resolved.
6
-
7
- def default_bundle_path
8
- Pathname.new("#{shared_path}/bundle")
9
- end
10
-
11
- namespace :load do
12
- task :defaults do
13
- # This provides opt-in behavior. Do nothing if not requested.
14
- set :bundler2_config_use_hook, fetch(:bundler2_config_use_hook, false)
15
- set :bundler2_config_roles, fetch(:bundler2_config_roles, [:app])
16
- set :bundler2_config_deployment, fetch(:bundler2_config_deployment, true)
17
- set :bundler2_config_without, fetch(:bundler2_config_without, 'development:test')
18
- # NOTE: `shared_path` is not defined at this point, so we can't set the default value to `default_bundle_path`
19
- set :bundler2_config_path, fetch(:bundler2_config_path, nil)
20
- end
21
- end
22
-
23
- # Integrate bundle config hook into Capistrano
24
- namespace :deploy do
25
- before :starting, :add_bundler2_config_hook do
26
- invoke 'bundler2:add_hook' if fetch(:bundler2_config_use_hook)
27
- end
28
- end
29
-
30
- namespace :bundler2 do
31
- # NOTE: no `desc` here to avoid publishing this task in the `cap -T` list
32
- task :add_hook do
33
- # Override capistrano-bundler settings
34
- # HT: https://github.com/capistrano/bundler/issues/115#issuecomment-616570236
35
- set :bundle_flags, '--quiet' # this unsets --deployment, see details in config_bundler task details
36
- set :bundle_path, nil
37
- set :bundle_without, nil
38
-
39
- before 'bundler:install', 'bundler2:config'
40
- end
41
-
42
- # NOTE: This task lacks a `desc` to avoid publishing it, since we do not
43
- # foresee needing to run this task manually. It should run via hook.
44
- #
45
- # Configure bundler 2 without using deprecated arguments (overrides capistrano-bundler
46
- task :config do
47
- on roles fetch(:bundler2_config_roles) do
48
- execute "bundle config --local deployment #{fetch(:bundler2_config_deployment)}"
49
- execute "bundle config --local without '#{fetch(:bundler2_config_without)}'"
50
- execute "bundle config --local path #{fetch(:bundler2_config_path) || default_bundle_path}"
51
- end
52
- end
53
- end