makandra_sidekiq 0.1.2 → 0.2.2

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
- SHA1:
3
- metadata.gz: cdf2b37120431a87cfb6a7033e7cd8b011ceec8f
4
- data.tar.gz: a5b3dd8b2a3c7255304bfd0354334026d6d97ac6
2
+ SHA256:
3
+ metadata.gz: 4b7815d7db44b5727181001de66b8d0dafef348e0df56076cf28794175354de1
4
+ data.tar.gz: d69af72a41fa909214a98b5bafeee7268a8bd0925a852baba677028c79ca238b
5
5
  SHA512:
6
- metadata.gz: b814fd76bcb8ad021a9c401dbeeb60fc3cef1260a70bcf7460f64dcd6596745128f8a25e655381179fb0b5b2a805b271aa5e6ee4894a25256d1591dc9ac10640
7
- data.tar.gz: e2ba1646f82d892a275c708f29224d749cce5382b909691154469d3c078535ec496f377d57cf1e1795550c84fa9829858cc27ca4e279350be8931bb898dfc954
6
+ metadata.gz: 3fc415dc5f85d4ea97bfec1c5a0093afeb6f51988902e47de17026a56ab942ad5d077a9a8e1ac37de83676515f988e1c09a3e66f8e04e01542c8e72abdf0ec49
7
+ data.tar.gz: 8d6b37d81fecaed42de082c477f259232acef7e0378647f366c373e3040b3e426b703ebba71b47efc1742ea466b1c4bda38e4c807574f03d7a6748ad58df4352
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.6
@@ -1,12 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ dist: trusty
3
4
  rvm:
4
- - 2.3.1
5
+ - 2.3.3
5
6
  script: bundle exec rspec spec
6
7
  cache: bundler
7
- notifications:
8
- email:
9
- - fail@makandra.de
10
8
  branches:
11
9
  only:
12
10
  - master
@@ -1,16 +1,46 @@
1
- # makandra_sidekiq change log
2
-
1
+ # Changelog
3
2
  All notable changes to this project will be documented in this file.
4
3
 
5
- ## [0.1.2][] (2017-01-12)
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
- ## [0.1.1][] (2016-09-29)
37
+ ## 0.1.1 2016-09-29
10
38
 
11
- Do not fail on first deploy.
39
+ ### Fixed
40
+ - Do not fail on first deploy.
12
41
 
13
42
 
14
- ## [0.1.0][] (2016-09-29)
43
+ ## 0.1.0 2016-09-29
15
44
 
16
- Initial release.
45
+ ### Added
46
+ - Initial release.
@@ -1,27 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- makandra_sidekiq (0.1.2)
5
- capistrano (>= 3)
4
+ makandra_sidekiq (0.2.1)
5
+ sidekiq (< 6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- airbrussh (1.1.1)
11
- sshkit (>= 1.6.1, != 1.7.0)
12
- capistrano (3.6.1)
13
- airbrussh (>= 1.0.0)
14
- capistrano-harrow
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
- sshkit (1.11.3)
39
- net-scp (>= 1.1.2)
40
- net-ssh (>= 2.8.0)
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.13.1
46
+ 1.17.2
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # makandra_sidekiq [![Build Status](https://travis-ci.org/makandra/makandra_sidekiq.svg?branch=master)](https://travis-ci.org/makandra/makandra_sidekiq)
2
2
 
3
- Support code for our default sidekiq setup.
3
+ Support code for our default Sidekiq setup.
4
4
 
5
- Includes rake tasks to start and stop sidekiq, capistrano recipes for deployment, and a way to restart sidekiq on reboot.
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 requires [capistrano](https://github.com/capistrano/capistrano) >= 3.
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 @reboot task to your crontab.
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
- run_sidekiqctl('quiet')
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
- run_sidekiqctl('stop')
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
- # not running
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 run_sidekiqctl(command)
97
- bundle_exec('sidekiqctl', command, pid_file.to_s)
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
- stdout_str, stderr_str, status = Open3.capture3('bundle', 'exec', *command, chdir: @root.to_s)
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
@@ -1,3 +1,3 @@
1
1
  module MakandraSidekiq
2
- VERSION = "0.1.2"
2
+ VERSION = '0.2.2'
3
3
  end
@@ -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 'capistrano', '>= 3'
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.1.2
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: 2017-01-12 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: capistrano
14
+ name: sidekiq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '3'
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: '3'
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
- rubyforge_project:
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: