makandra_sidekiq 0.1.2 → 0.2.2
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 +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +2 -4
- data/CHANGELOG.md +38 -8
- data/Gemfile.lock +14 -20
- data/README.md +19 -6
- data/lib/makandra_sidekiq/sidekiq_control.rb +45 -8
- data/lib/makandra_sidekiq/version.rb +1 -1
- data/makandra_sidekiq.gemspec +1 -1
- metadata +8 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4b7815d7db44b5727181001de66b8d0dafef348e0df56076cf28794175354de1
|
|
4
|
+
data.tar.gz: d69af72a41fa909214a98b5bafeee7268a8bd0925a852baba677028c79ca238b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fc415dc5f85d4ea97bfec1c5a0093afeb6f51988902e47de17026a56ab942ad5d077a9a8e1ac37de83676515f988e1c09a3e66f8e04e01542c8e72abdf0ec49
|
|
7
|
+
data.tar.gz: 8d6b37d81fecaed42de082c477f259232acef7e0378647f366c373e3040b3e426b703ebba71b47efc1742ea466b1c4bda38e4c807574f03d7a6748ad58df4352
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,46 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Changelog
|
|
3
2
|
All notable changes to this project will be documented in this file.
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 0.2.1 2020-05-18
|
|
11
|
+
|
|
12
|
+
### Compatible changes
|
|
13
|
+
- Fixed deprecation warnings on modern Bundlers. We are now using `Bundler.with_original_env`.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 0.2.0 2019-11-08
|
|
17
|
+
|
|
18
|
+
### Compatible changes
|
|
19
|
+
- Added CHANGELOG to satisfy [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
20
|
+
- Fix: now considering the configured Sidekiq timeout when running
|
|
21
|
+
`sidekiqctl stop` through `sidekiq:stop`. Previously, long-running jobs would
|
|
22
|
+
get lost!
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 0.1.3 2017-02-13
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- Gem no longer depends on `capistrano`, since using its Capistrano recipes is optional.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## 0.1.2 2017-01-12
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- `sidekiq:start` checks that sidekiq really comes up and will retry a few times.
|
|
6
35
|
|
|
7
|
-
`sidekiq:start` checks that sidekiq really comes up and will retry a few times.
|
|
8
36
|
|
|
9
|
-
##
|
|
37
|
+
## 0.1.1 2016-09-29
|
|
10
38
|
|
|
11
|
-
|
|
39
|
+
### Fixed
|
|
40
|
+
- Do not fail on first deploy.
|
|
12
41
|
|
|
13
42
|
|
|
14
|
-
##
|
|
43
|
+
## 0.1.0 2016-09-29
|
|
15
44
|
|
|
16
|
-
|
|
45
|
+
### Added
|
|
46
|
+
- Initial release.
|
data/Gemfile.lock
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
makandra_sidekiq (0.1
|
|
5
|
-
|
|
4
|
+
makandra_sidekiq (0.2.1)
|
|
5
|
+
sidekiq (< 6)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
i18n
|
|
16
|
-
rake (>= 10.0.0)
|
|
17
|
-
sshkit (>= 1.9.0)
|
|
18
|
-
capistrano-harrow (0.5.3)
|
|
19
|
-
diff-lcs (1.2.5)
|
|
20
|
-
i18n (0.7.0)
|
|
21
|
-
net-scp (1.2.1)
|
|
22
|
-
net-ssh (>= 2.6.5)
|
|
23
|
-
net-ssh (3.2.0)
|
|
10
|
+
connection_pool (2.2.2)
|
|
11
|
+
diff-lcs (1.3)
|
|
12
|
+
rack (2.0.9)
|
|
13
|
+
rack-protection (2.0.8.1)
|
|
14
|
+
rack
|
|
24
15
|
rake (10.5.0)
|
|
16
|
+
redis (4.1.4)
|
|
25
17
|
rspec (3.5.0)
|
|
26
18
|
rspec-core (~> 3.5.0)
|
|
27
19
|
rspec-expectations (~> 3.5.0)
|
|
@@ -35,9 +27,11 @@ GEM
|
|
|
35
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
28
|
rspec-support (~> 3.5.0)
|
|
37
29
|
rspec-support (3.5.0)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
sidekiq (5.2.8)
|
|
31
|
+
connection_pool (~> 2.2, >= 2.2.2)
|
|
32
|
+
rack (< 2.1.0)
|
|
33
|
+
rack-protection (>= 1.5.0)
|
|
34
|
+
redis (>= 3.3.5, < 5)
|
|
41
35
|
|
|
42
36
|
PLATFORMS
|
|
43
37
|
ruby
|
|
@@ -49,4 +43,4 @@ DEPENDENCIES
|
|
|
49
43
|
rspec (~> 3.0)
|
|
50
44
|
|
|
51
45
|
BUNDLED WITH
|
|
52
|
-
1.
|
|
46
|
+
1.17.2
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# makandra_sidekiq [](https://travis-ci.org/makandra/makandra_sidekiq)
|
|
2
2
|
|
|
3
|
-
Support code for our default
|
|
3
|
+
Support code for our default Sidekiq setup.
|
|
4
4
|
|
|
5
|
-
Includes rake tasks to start and stop
|
|
5
|
+
Includes rake tasks to start and stop Sidekiq, Capistrano recipes for deployment, and a way to restart Sidekiq on reboot.
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
@@ -27,9 +27,22 @@ Make sure you include at least `:pidfile` and `:logfile`. Sane values are
|
|
|
27
27
|
:logfile: ./log/sidekiq.log
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
|
|
31
|
+
### Passing additional options to sidekiq
|
|
32
|
+
|
|
33
|
+
Sometimes you will have to pass additional options to the sidekiq binary. You can do this by adding
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
:sidekiq_command_line_args: '--some --options'
|
|
37
|
+
```
|
|
38
|
+
to your `config/sidekiq.yml`.
|
|
39
|
+
|
|
40
|
+
|
|
30
41
|
### Capistrano
|
|
31
42
|
|
|
32
|
-
makandra_sidekiq
|
|
43
|
+
makandra_sidekiq comes with [Capistrano](https://github.com/capistrano/capistrano) recipes to call its rake tasks for (re)starting Sidekiq during deployment.
|
|
44
|
+
|
|
45
|
+
Note that those recipes require Capistrano 3+.
|
|
33
46
|
|
|
34
47
|
- Add the following line to your Capfile:
|
|
35
48
|
|
|
@@ -44,19 +57,19 @@ makandra_sidekiq requires [capistrano](https://github.com/capistrano/capistrano)
|
|
|
44
57
|
|
|
45
58
|
### Restart sidekiq on reboot
|
|
46
59
|
|
|
47
|
-
Simply add `rake sidekiq:start` as a
|
|
60
|
+
Simply add `rake sidekiq:start` as a `@reboot` task to your crontab.
|
|
48
61
|
|
|
49
62
|
When using [whenever](https://github.com/javan/whenever), add this to your schedule.rb:
|
|
50
63
|
|
|
51
64
|
```
|
|
52
65
|
every :reboot do
|
|
53
|
-
rake 'sidekiq:start'
|
|
66
|
+
rake 'sidekiq:start', output: { standard: nil }
|
|
54
67
|
end
|
|
55
68
|
```
|
|
56
69
|
|
|
57
70
|
In case you don't use whenever, this crontab entry will work:
|
|
58
71
|
```
|
|
59
|
-
@reboot /bin/bash -l -c 'cd /path/to/rails/root && RAILS_ENV=environment bundle exec rake sidekiq:start --silent'
|
|
72
|
+
@reboot /bin/bash -l -c 'cd /path/to/rails/root && RAILS_ENV=environment bundle exec rake sidekiq:start --silent > /dev/null'
|
|
60
73
|
```
|
|
61
74
|
|
|
62
75
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
require 'sidekiq'
|
|
1
3
|
require 'pathname'
|
|
2
4
|
require 'yaml'
|
|
3
5
|
require 'open3'
|
|
@@ -16,7 +18,7 @@ module MakandraSidekiq
|
|
|
16
18
|
def quiet
|
|
17
19
|
if running?
|
|
18
20
|
puts 'Preventing Sidekiq from accepting new jobs...'
|
|
19
|
-
|
|
21
|
+
sidekiqctl_quiet
|
|
20
22
|
else
|
|
21
23
|
puts 'Sidekiq is not running.'
|
|
22
24
|
end
|
|
@@ -25,7 +27,7 @@ module MakandraSidekiq
|
|
|
25
27
|
def stop
|
|
26
28
|
if running?
|
|
27
29
|
puts 'Stopping Sidekiq...'
|
|
28
|
-
|
|
30
|
+
sidekiqctl_stop
|
|
29
31
|
else
|
|
30
32
|
puts 'Sidekiq is not running.'
|
|
31
33
|
end
|
|
@@ -55,6 +57,11 @@ module MakandraSidekiq
|
|
|
55
57
|
@pid_file ||= @root.join(@config[:pidfile])
|
|
56
58
|
end
|
|
57
59
|
|
|
60
|
+
# The shutdown timeout for Sidekiq
|
|
61
|
+
def timeout
|
|
62
|
+
@timeout ||= @config[:timeout] || Sidekiq::DEFAULTS[:timeout]
|
|
63
|
+
end
|
|
64
|
+
|
|
58
65
|
def read_pid
|
|
59
66
|
if pid_file.file?
|
|
60
67
|
pid_file.read.to_i
|
|
@@ -63,9 +70,12 @@ module MakandraSidekiq
|
|
|
63
70
|
|
|
64
71
|
def running?
|
|
65
72
|
pid = read_pid
|
|
66
|
-
Process.kill(0, pid) if pid
|
|
73
|
+
Process.kill(0, pid) if pid # kill(0, pid) checks pid validity
|
|
67
74
|
rescue Errno::ESRCH
|
|
68
|
-
#
|
|
75
|
+
false # Not running
|
|
76
|
+
rescue Errno::EPERM
|
|
77
|
+
# The process from Sidekiq's pidfile does not belong to us. This can occur
|
|
78
|
+
# when Sidekiq for some reason stopped but left behind its pidfile.
|
|
69
79
|
false
|
|
70
80
|
end
|
|
71
81
|
|
|
@@ -93,8 +103,16 @@ module MakandraSidekiq
|
|
|
93
103
|
config
|
|
94
104
|
end
|
|
95
105
|
|
|
96
|
-
def
|
|
97
|
-
bundle_exec
|
|
106
|
+
def sidekiqctl_quiet
|
|
107
|
+
bundle_exec 'sidekiqctl', 'quiet', pid_file
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def sidekiqctl_stop
|
|
111
|
+
# The "hard kill after" timeout for sidekiqctl. Adding a few seconds to be
|
|
112
|
+
# sure that jobs running at shutdown are requeued by Sidekiq.
|
|
113
|
+
safe_timeout = timeout + 2 # seconds
|
|
114
|
+
|
|
115
|
+
bundle_exec 'sidekiqctl', 'stop', pid_file, safe_timeout
|
|
98
116
|
end
|
|
99
117
|
|
|
100
118
|
def patiently_start_sidekiq
|
|
@@ -131,22 +149,41 @@ module MakandraSidekiq
|
|
|
131
149
|
'--index', sidekiq_index.to_s,
|
|
132
150
|
'--environment', rails_env,
|
|
133
151
|
'--config', config_path.to_s,
|
|
134
|
-
'--daemon'
|
|
152
|
+
'--daemon',
|
|
153
|
+
*additional_command_line_args,
|
|
135
154
|
]
|
|
136
155
|
bundle_exec('sidekiq', *arguments)
|
|
137
156
|
end
|
|
138
157
|
|
|
158
|
+
def additional_command_line_args
|
|
159
|
+
if (raw_args = @config[:sidekiq_command_line_args])
|
|
160
|
+
raw_args.split(' ')
|
|
161
|
+
else
|
|
162
|
+
[]
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
139
166
|
def sidekiq_index
|
|
140
167
|
ENV['SIDEKIQ_INDEX'] || 0
|
|
141
168
|
end
|
|
142
169
|
|
|
143
170
|
def bundle_exec(*command)
|
|
144
|
-
|
|
171
|
+
string_command = command.map(&:to_s)
|
|
172
|
+
root = @root.to_s
|
|
173
|
+
stdout_str, stderr_str, status = with_original_env { capture3('bundle', 'exec', *string_command, chdir: root) }
|
|
145
174
|
puts stdout_str
|
|
146
175
|
unless status.success?
|
|
147
176
|
fail "#{command} failed with message: #{stderr_str}"
|
|
148
177
|
end
|
|
149
178
|
end
|
|
150
179
|
|
|
180
|
+
def capture3(*command)
|
|
181
|
+
Open3.capture3(*command)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def with_original_env(&block)
|
|
185
|
+
Bundler.with_original_env(&block)
|
|
186
|
+
end
|
|
187
|
+
|
|
151
188
|
end
|
|
152
189
|
end
|
data/makandra_sidekiq.gemspec
CHANGED
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
18
18
|
spec.require_paths = ["lib"]
|
|
19
19
|
|
|
20
|
-
spec.add_dependency
|
|
20
|
+
spec.add_dependency "sidekiq", "< 6"
|
|
21
21
|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.12"
|
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: makandra_sidekiq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: sidekiq
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "<"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "<"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -110,10 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
111
|
version: '0'
|
|
112
112
|
requirements: []
|
|
113
|
-
|
|
114
|
-
rubygems_version: 2.6.6
|
|
113
|
+
rubygems_version: 3.0.3
|
|
115
114
|
signing_key:
|
|
116
115
|
specification_version: 4
|
|
117
116
|
summary: Support code for sidekiq, including rake tasks and capistrano recipes.
|
|
118
117
|
test_files: []
|
|
119
|
-
has_rdoc:
|