sidekiq-pool 1.8.0 → 1.9.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: fbcd18cd80b67101d003aae7aef8f1747357de29536bbb9ebaabc85baf2768a5
4
- data.tar.gz: 628eb6ba736ecf768bab6bc7d336480c20bfbd3c4152eaf3f521977448d26041
3
+ metadata.gz: bf98a1a08f14125a21317d2846177402c75beea40e6204e63889db1bd43320ca
4
+ data.tar.gz: f3d39f372b981c12c312e4cd76fd7788bcdcea1122aa320fa12290195798eaaf
5
5
  SHA512:
6
- metadata.gz: 16ef09872093ea84ff7ef3c2082332443ba1973185ffc900b30a8e41ddb4c1f53f7ba85d298eb652d817c4a7e9c68a0034a89d1f5819a4cc1fce93c07da31b91
7
- data.tar.gz: 9a3536806744212ea3de7f3f5f814a39c028361f9193afa85cc1300b0dfd5fefc108d2de98cafb0b3f0e8637e0347c8edaec0b36daa70715af0ab78c9d866329
6
+ metadata.gz: f23137a068a0e6d9a8736df5104875b88c7ed0e70189ad7753cea33c5c62a3e522be30556745b63b1c8ec2656eea135739b361adc70196ec604b2cc3f2ce7d3f
7
+ data.tar.gz: f82f7f8bed62b0f5e8768c35710eadbb938c21609a0493a050a5227c7b75276e3bd196d123ecbabe2f8bda6976a03c426d2a81171caf6e46194f36bfdc4d223e
@@ -0,0 +1,54 @@
1
+ name: Build and release ruby gem
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ master ]
6
+ push:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build-release-pipeline:
11
+ runs-on: ubuntu-latest
12
+ container: ruby:2.7.2
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Setup
16
+ run: |
17
+ apt-get update -y && apt-get install -y --no-install-recommends cmake=3.13.4-1
18
+ gem install bundler
19
+ bundle install
20
+
21
+ - name: Test
22
+ run: bundle exec rake
23
+
24
+ - name: Build
25
+ id: build
26
+ if: success() && github.ref == 'refs/heads/master'
27
+ run: |
28
+ bundle exec rake build
29
+ echo "::set-output name=gem_version::v$(bundle exec rake version)"
30
+
31
+ - name: Release
32
+ if: success() && github.ref == 'refs/heads/master'
33
+ run: |
34
+ mkdir -p $HOME/.gem
35
+ touch $HOME/.gem/credentials
36
+ chmod 600 $HOME/.gem/credentials
37
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
38
+ gem push pkg/*
39
+ env:
40
+ GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
41
+
42
+ - name: Tag repo with new gem version
43
+ if: success() && github.ref == 'refs/heads/master'
44
+ uses: actions/github-script@v3
45
+ with:
46
+ github-token: ${{ github.token }}
47
+ script: |
48
+ github.git.createRef({
49
+ owner: context.repo.owner,
50
+ repo: context.repo.repo,
51
+ ref: "refs/tags/${{ steps.build.outputs.gem_version }}",
52
+ sha: context.sha
53
+ })
54
+
data/Rakefile CHANGED
@@ -4,3 +4,7 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ task :version do |t|
9
+ puts Sidekiq::Pool::VERSION
10
+ end
@@ -11,7 +11,6 @@ module Sidekiq
11
11
  }
12
12
 
13
13
  def initialize
14
- @child_index = 0
15
14
  @pool = []
16
15
  @done = false
17
16
  @system_booted = false
@@ -20,8 +19,13 @@ module Sidekiq
20
19
 
21
20
  alias_method :run_child, :run
22
21
 
22
+ def write_pid
23
+ super if @master_pid == ::Process.pid
24
+ end
25
+
23
26
  def run
24
27
  @master_pid = $$
28
+ write_pid
25
29
 
26
30
  trap_signals
27
31
  update_process_name
@@ -69,10 +73,12 @@ module Sidekiq
69
73
  boot_system
70
74
 
71
75
  @types = @settings[:workers]
76
+ index = -1
72
77
  @types.each do |type|
73
78
  type[:amount].times do
79
+ index += 1
74
80
  sleep @fork_wait || DEFAULT_FORK_WAIT
75
- fork_child(type[:command])
81
+ fork_child(type[:command], index)
76
82
  end
77
83
  end
78
84
  drop_reload_marker
@@ -189,7 +195,7 @@ module Sidekiq
189
195
  end
190
196
  end
191
197
 
192
- def fork_child(command, wait_for_busy = true)
198
+ def fork_child(command, index, wait_for_busy = true)
193
199
  logger.info "Adding child with args: (#{command}) in #{working_directory}, waiting for busy: #{wait_for_busy}"
194
200
  if working_directory && !Dir.exist?(working_directory)
195
201
  logger.info "Working directory: #{working_directory} does not exist unable to fork"
@@ -203,13 +209,13 @@ module Sidekiq
203
209
 
204
210
  @self_write.close
205
211
  $0 = 'sidekiq starting'
206
- @child_index += 1
207
- options[:index] = @child_index
212
+ options[:index] = index
208
213
 
209
214
  # reset child identity
210
215
  @@process_nonce = nil
211
216
  @@identity = nil
212
217
  options[:identity] = identity
218
+ options[:tag] = "worker #{index}"
213
219
 
214
220
  run_after_fork_hooks
215
221
  run_child
@@ -223,7 +229,7 @@ module Sidekiq
223
229
  sleep 1
224
230
  end if wait_for_busy
225
231
 
226
- @pool << { pid: pid, command: command }
232
+ @pool << { pid: pid, index: index, command: command }
227
233
  end
228
234
 
229
235
  def wait_for_signals
@@ -309,9 +315,9 @@ module Sidekiq
309
315
  end
310
316
 
311
317
  def handle_dead_child(child)
312
- logger.info "Child #{child[:pid]} died"
318
+ logger.info "Child #{child[:pid]} (worker #{child[:index]}) died"
313
319
  @pool.delete(child)
314
- fork_child(child[:command], false)
320
+ fork_child(child[:command], child[:index], false)
315
321
  end
316
322
 
317
323
  def alive?(pid)
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Pool
3
- VERSION = '1.8.0'
3
+ VERSION = '1.9.1'
4
4
  end
5
5
  end
data/sidekiq-pool.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'sidekiq/pool/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'sidekiq-pool'
8
8
  spec.version = Sidekiq::Pool::VERSION
9
- spec.authors = ['Laurynas Butkus', 'Raimondas Valickas']
10
- spec.email = ['laurynas.butkus@gmail.com', 'raimondas.valickas@gmail.com']
9
+ spec.authors = ['Vinted']
10
+ spec.email = ['backend@vinted.com']
11
11
 
12
12
  spec.summary = %q{Forks and manages multiple Sidekiq processes}
13
13
  spec.description = %q{Allows Sidekiq using more CPU cores on Ruby MRI by forking multiple processes.}
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
- - Laurynas Butkus
8
- - Raimondas Valickas
7
+ - Vinted
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sidekiq
@@ -89,17 +88,16 @@ dependencies:
89
88
  version: '3.0'
90
89
  description: Allows Sidekiq using more CPU cores on Ruby MRI by forking multiple processes.
91
90
  email:
92
- - laurynas.butkus@gmail.com
93
- - raimondas.valickas@gmail.com
91
+ - backend@vinted.com
94
92
  executables:
95
93
  - sidekiq-pool
96
94
  extensions: []
97
95
  extra_rdoc_files: []
98
96
  files:
97
+ - ".github/workflows/build_release_pipeline.yaml"
99
98
  - ".gitignore"
100
99
  - ".rspec"
101
100
  - ".rubocop.yml"
102
- - ".travis.yml"
103
101
  - Gemfile
104
102
  - LICENSE.txt
105
103
  - README.md
@@ -129,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
127
  - !ruby/object:Gem::Version
130
128
  version: '0'
131
129
  requirements: []
132
- rubygems_version: 3.0.3
130
+ rubygems_version: 3.1.4
133
131
  signing_key:
134
132
  specification_version: 4
135
133
  summary: Forks and manages multiple Sidekiq processes
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - ruby-head
4
- - 2.7.0
5
- - 2.6.5
6
- - 2.5.1
7
- - 2.4.1
8
- - 2.3.4
9
- before_install: gem install bundler
10
- after_success:
11
- - >
12
- [ "${TRAVIS_PULL_REQUEST}" != "false" ] &&
13
- [ "${TRAVIS_RUBY_VERSION}" = "2.5.1" ] &&
14
- PRONTO_PULL_REQUEST_ID=${TRAVIS_PULL_REQUEST} \
15
- bundle exec pronto run -f github_status github_pr -c origin/${TRAVIS_BRANCH}