dlss-capistrano 3.5.0 → 3.6.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 +59 -7
- data/dlss-capistrano.gemspec +6 -6
- data/lib/dlss/capistrano.rb +2 -0
- data/lib/dlss/capistrano/tasks/bundle_config.rake +53 -0
- data/lib/dlss/capistrano/tasks/sidekiq_systemd.rake +52 -0
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8f550ec45bd1d6633ac6868fc417aefc33b64ba8ef8134b14cb40f61c01c48
|
4
|
+
data.tar.gz: 2d1d900f77b688e06e7ccfaa314494307947b0a43ac19bdda7b0c163263f19f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e1f76b839e71f7aaf1103d865ab0a30051161d3dd8360d525ee0486c554409a0ddcf8758f4b5081e36815710caa4d484790cab04f675e378a0f4fdcae97394
|
7
|
+
data.tar.gz: a266d77daf559af7cf561587f4ed5e47e27d79dad8afe835d3f38884cbb23cdd64f81dd5ecad3acdb6adc998540d57c3115ed071b971d5392abb248de5dadcea
|
data/README.md
CHANGED
@@ -1,20 +1,72 @@
|
|
1
1
|
# dlss-capistrano
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/dlss-capistrano.svg)](https://badge.fury.io/rb/dlss-capistrano)
|
4
4
|
|
5
|
-
|
5
|
+
This gem provides Capistrano deployment tasks used by Stanford Libraries' Digital Library Systems and Services group.
|
6
6
|
|
7
|
-
|
7
|
+
## Included Tasks
|
8
|
+
|
9
|
+
### Bundle 2-style Configuration
|
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`:
|
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
|
19
|
+
```
|
20
|
+
|
21
|
+
Note that only `bundler2_config_use_hook` **must** be set in order to use this functionality.
|
22
|
+
|
23
|
+
### SSH
|
24
|
+
|
25
|
+
`cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory
|
26
|
+
|
27
|
+
### Sidekiq via systemd
|
28
|
+
|
29
|
+
`cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
#### Capistrano role
|
34
|
+
|
35
|
+
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.*:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
set :sidekiq_systemd_role, :worker
|
39
|
+
```
|
40
|
+
|
41
|
+
#### Deployment hooks
|
42
|
+
|
43
|
+
The sidekiq_systemd tasks assume you want to hook them into Capistrano deployment on your own. If you want to use the hooks provided by `dlss-capistrano`, you can opt in via `config/deploy.rb`:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
set :sidekiq_systemd_use_hooks, true
|
47
|
+
```
|
48
|
+
|
49
|
+
These are the hooks provided if you opt in:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
after 'deploy:failed', 'sidekiq_systemd:restart'
|
53
|
+
after 'deploy:published', 'sidekiq_systemd:start'
|
54
|
+
after 'deploy:starting', 'sidekiq_systemd:quiet'
|
55
|
+
after 'deploy:updated', 'sidekiq_systemd:stop'
|
56
|
+
```
|
57
|
+
|
58
|
+
## Assumptions
|
59
|
+
|
60
|
+
dlss-capistrano makes the following assumptions about your Ruby project
|
8
61
|
|
9
62
|
- You are using Capistrano 3+
|
10
63
|
- You use git for source control
|
11
|
-
- The server you deploy to uses rvm, it is installed
|
64
|
+
- The server you deploy to uses rvm, it is installed system-wide, and is the default system ruby
|
12
65
|
- You do not have an .rvmrc checked into git (should be in your .gitignore)
|
13
66
|
- You will not use rvm gemsets on the server you deploy to
|
14
67
|
- Bundler will install specified gems into {your_project_home}/shared/bundle directory
|
15
68
|
- Will deploy from the master branch, unless you set :branch to another branch or tag
|
16
69
|
|
70
|
+
## Copyright
|
17
71
|
|
18
|
-
|
19
|
-
|
20
|
-
Copyright (c) 2015 Stanford University Library. See LICENSE for details.
|
72
|
+
Copyright (c) 2020 Stanford University. See LICENSE for details.
|
data/dlss-capistrano.gemspec
CHANGED
@@ -4,13 +4,13 @@ $:.unshift lib unless $:.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "dlss-capistrano"
|
7
|
-
s.version = "3.
|
7
|
+
s.version = "3.6.0"
|
8
8
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.authors = ["Chris Beer",
|
11
|
-
s.email = ["cabeer@stanford.edu"]
|
12
|
-
s.summary = "Capistrano
|
13
|
-
s.description = "Capistrano
|
10
|
+
s.authors = ["Chris Beer", 'Mike Giarlo']
|
11
|
+
s.email = ["cabeer@stanford.edu", 'mjgiarlo@stanford.edu']
|
12
|
+
s.summary = "Capistrano recipes for use in SUL/DLSS projects"
|
13
|
+
s.description = "Capistrano recipes to assist with development, testing, & deployment of SUL/DLSS Ruby projects"
|
14
14
|
s.license = "Apache-2.0"
|
15
15
|
|
16
16
|
s.required_rubygems_version = ">= 1.3.6"
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
# All dependencies are runtime dependencies, since this gem's "runtime" is
|
20
20
|
# the dependent gem's development-time.
|
21
21
|
s.add_dependency "capistrano", "~> 3.0"
|
22
|
-
s.add_dependency "capistrano-bundle_audit", ">= 0.
|
22
|
+
s.add_dependency "capistrano-bundle_audit", ">= 0.3.0"
|
23
23
|
s.add_dependency "capistrano-one_time_key"
|
24
24
|
s.add_dependency "capistrano-shared_configs"
|
25
25
|
|
data/lib/dlss/capistrano.rb
CHANGED
@@ -2,4 +2,6 @@ require 'capistrano/one_time_key'
|
|
2
2
|
require 'capistrano/bundle_audit'
|
3
3
|
require 'capistrano/shared_configs'
|
4
4
|
|
5
|
+
load File.expand_path('../capistrano/tasks/bundle_config.rake', __FILE__)
|
6
|
+
load File.expand_path('../capistrano/tasks/sidekiq_systemd.rake', __FILE__)
|
5
7
|
load File.expand_path('../capistrano/tasks/ssh.rake', __FILE__)
|
@@ -0,0 +1,53 @@
|
|
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
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Capistrano plugin hook to set default values
|
2
|
+
namespace :load do
|
3
|
+
task :defaults do
|
4
|
+
set :sidekiq_systemd_role, fetch(:sidekiq_systemd_role, :app)
|
5
|
+
set :sidekiq_systemd_use_hooks, fetch(:sidekiq_systemd_use_hooks, false)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Integrate sidekiq hooks into Capistrano
|
10
|
+
namespace :deploy do
|
11
|
+
before :starting, :add_sidekiq_systemd_hooks do
|
12
|
+
invoke 'sidekiq_systemd:add_hooks' if fetch(:sidekiq_systemd_use_hooks)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :sidekiq_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', 'sidekiq_systemd:restart'
|
20
|
+
after 'deploy:published', 'sidekiq_systemd:start'
|
21
|
+
after 'deploy:starting', 'sidekiq_systemd:quiet'
|
22
|
+
after 'deploy:updated', 'sidekiq_systemd:stop'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Stop workers from picking up new jobs'
|
26
|
+
task :quiet do
|
27
|
+
on roles fetch(:sidekiq_systemd_role) do
|
28
|
+
sudo :systemctl, 'reload', 'sidekiq-*', 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(:sidekiq_systemd_role) do
|
35
|
+
sudo :systemctl, 'stop', 'sidekiq-*'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Start workers'
|
40
|
+
task :start do
|
41
|
+
on roles fetch(:sidekiq_systemd_role) do
|
42
|
+
sudo :systemctl, 'start', 'sidekiq-*', '--all'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Restart workers'
|
47
|
+
task :restart do
|
48
|
+
on roles fetch(:sidekiq_systemd_role) do
|
49
|
+
sudo :systemctl, 'restart', 'sidekiq-*', raise_on_non_zero_exit: false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dlss-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
|
-
-
|
8
|
+
- Mike Giarlo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 0.3.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.
|
41
|
+
version: 0.3.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: capistrano-one_time_key
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,10 +67,11 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
description: Capistrano
|
71
|
-
of SUL/DLSS Ruby
|
70
|
+
description: Capistrano recipes to assist with development, testing, & deployment
|
71
|
+
of SUL/DLSS Ruby projects
|
72
72
|
email:
|
73
73
|
- cabeer@stanford.edu
|
74
|
+
- mjgiarlo@stanford.edu
|
74
75
|
executables: []
|
75
76
|
extensions: []
|
76
77
|
extra_rdoc_files: []
|
@@ -83,6 +84,8 @@ files:
|
|
83
84
|
- dlss-capistrano.gemspec
|
84
85
|
- lib/dlss.rb
|
85
86
|
- lib/dlss/capistrano.rb
|
87
|
+
- lib/dlss/capistrano/tasks/bundle_config.rake
|
88
|
+
- lib/dlss/capistrano/tasks/sidekiq_systemd.rake
|
86
89
|
- lib/dlss/capistrano/tasks/ssh.rake
|
87
90
|
- lib/lyberteam-capistrano-devel.rb
|
88
91
|
homepage:
|
@@ -104,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
107
|
- !ruby/object:Gem::Version
|
105
108
|
version: 1.3.6
|
106
109
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.7.6
|
110
|
+
rubygems_version: 3.0.3
|
109
111
|
signing_key:
|
110
112
|
specification_version: 4
|
111
|
-
summary: Capistrano
|
113
|
+
summary: Capistrano recipes for use in SUL/DLSS projects
|
112
114
|
test_files: []
|