worker_killer 0.0.9.19836 → 0.1.0.19839

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: 6afd0ad3285687093b9b10b00153eb82e127939acff50aeb0e34c29380058120
4
- data.tar.gz: e8ce002079c3caf5681ec11db247bbdd3a4dab124cd06929c28a821a4ae6235d
3
+ metadata.gz: 87ac13b4bd486015cd2e99a580fa311878b094b2dd621351c7b8997c476a50ff
4
+ data.tar.gz: 5635186d2b8cf8d7b25d72c639733ca603afea7406f3d0bb7e172ff7d52d941d
5
5
  SHA512:
6
- metadata.gz: 482658ddc4984d4571a2b1cf8469e23fed14aab4d6a8fa3131d7d21c07d840b2b89ba121d441163141f6e6ed9a068b3a726ee242e10b9f05da4ce38404ee9e08
7
- data.tar.gz: 248995d17c2e791a22d7e5af51849f0b421bdfef360c0c961bd346096d6959499a3b92b53b42495c8961291680e79239c45de3fef2f0d19e3618e6e8f98ac92c
6
+ metadata.gz: 6e72c3f683cc72d7e18937ec6cc2ae66281149418dad1dc26f1649a6a62f92009d15f643c292cb79a445b867d2305fae5198a8721a1a2b92350346f7f6d070bd
7
+ data.tar.gz: 85c8cd4872a38b99d2aed420ba52c69f14746e86d2ff12d61103c79b96c40fc35fb46770ac79f15f3b6d672d4857f2c15d44388efc052b0017bb494d3ea644e7
data/README.md CHANGED
@@ -1,43 +1,52 @@
1
- # unicorn-worker-killer
1
+ # worker-killer
2
2
 
3
- [Unicorn](http://unicorn.bogomips.org/) is widely used HTTP-server for Rack applications. One thing we thought Unicorn missed, is killing the Unicorn workers based on the number of requests and consumed memories.
3
+ Kill any workers by memory and request counts or take custom reaction. Inspired by [unicorn-worker-killer](https://github.com/kzk/unicorn-worker-killer).
4
4
 
5
- `unicorn-worker-killer` gem provides automatic restart of Unicorn workers based on 1) max number of requests, and 2) process memory size (RSS), without affecting any requests. This will greatly improves site's stability by avoiding unexpected memory exhaustion at the application nodes.
5
+ `worker-killer` gem provides automatic restart of Web-server based on 1) max number of requests, and 2) process memory size (RSS). This will greatly improves site's stability by avoiding unexpected memory exhaustion at the application nodes.
6
+
7
+ Features:
8
+
9
+ * generic middleware implementation
10
+ * custom reactin hook
11
+
12
+ Planned:
13
+
14
+ * DelayedJob support
6
15
 
7
16
  # Install
8
17
 
9
- No external process like `god` is required. Just install one gem: `unicorn-worker-killer`.
18
+ No external process like `god` is required. Just install one gem: `worker-killer`.
10
19
 
11
- gem 'unicorn-worker-killer'
20
+ gem 'worker-killer'
12
21
 
13
22
  # Usage
14
23
 
15
- Add these lines to your `config.ru`. (These lines should be added above the `require ::File.expand_path('../config/environment', __FILE__)` line.
24
+ Add these lines to your `config.ru` or `application.rb`. (These lines should be added above the `require ::File.expand_path('../config/environment', __FILE__)` line.
16
25
 
17
- # Unicorn self-process killer
18
- require 'unicorn/worker_killer'
26
+ # self-process killer
27
+ require 'worker_killer/middleware'
19
28
 
20
29
  # Max requests per worker
21
- use Unicorn::WorkerKiller::MaxRequests, 3072, 4096
30
+ config.middleware.insert_before(Rack::Sendfile, WorkerKiller::Middleware::RequestsLimiter, min: 4096, max: 5120)
22
31
 
23
32
  # Max memory size (RSS) per worker
24
- use Unicorn::WorkerKiller::Oom, (192*(1024**2)), (256*(1024**2))
33
+ config.middleware.insert_before(Rack::Sendfile, WorkerKiller::Middleware::OOMLimiter, min: 300 * (1024**2), max: 400 * (1024**2))
25
34
 
26
- This gem provides two modules.
35
+ This gem provides two modules: WorkerKiller::CountLimiter and WorkerKiller::MemoryLimiter and some Rack integration.
27
36
 
28
- ### `Unicorn::WorkerKiller::MaxRequests(max_requests_min=3072, max_requests_max=4096, verbose=false)`
37
+ ### `WorkerKiller::Middleware::RequestsLimiter`
29
38
 
30
- This module automatically restarts the Unicorn workers, based on the number of requests which worker processed.
39
+ This module automatically restarts the kill workers, based on the number of requests which worker processed.
31
40
 
32
- `max_requests_min` and `max_requests_max` specify the min and max of maximum requests per worker. The actual limit is decided by rand() between `max_requests_min` and `max_requests_max` per worker, to prevent all workers to be dead at the same time. Once the number exceeds the limit, that worker is automatically restarted.
41
+ `min` and `max` specify the min and max of maximum requests per worker. The actual limit is decided by rand() between `min` and `max` per worker, to prevent all workers to be dead at the same time. Once the number exceeds the limit, that worker is automatically restarted.
33
42
 
34
43
  If `verbose` is set to true, then after every request, your log will show the requests left before restart. This logging is done at the `info` level.
35
44
 
36
- ### `Unicorn::WorkerKiller::Oom(memory_limit_min=(1024\*\*3), memory_limit_max=(2\*(1024\*\*3)), check_cycle = 16, verbose = false)`
45
+ ### `WorkerKiller::Middleware::OOMLimiter`
37
46
 
38
47
  This module automatically restarts the Unicorn workers, based on its memory size.
39
48
 
40
- `memory_limit_min` and `memory_limit_max` specify the min and max of maximum memory in bytes per worker. The actual limit is decided by rand() between `memory_limit_min` and `memory_limit_max` per worker, to prevent all workers to be dead at the same time. Once the memory size exceeds `memory_size`, that worker is automatically restarted.
49
+ `min` and `max` specify the min and max of maximum memory in bytes per worker. The actual limit is decided by rand() between `min` and `max` per worker, to prevent all workers to be dead at the same time. Once the memory size exceeds `memory_size`, that worker is automatically restarted.
41
50
 
42
51
  The memory size check is done in every `check_cycle` requests.
43
52
 
@@ -46,4 +55,5 @@ If `verbose` is set to true, then every memory size check will be shown in your
46
55
  # Special Thanks
47
56
 
48
57
  - [@hotchpotch](http://github.com/hotchpotch/) for the [original idea](https://gist.github.com/hotchpotch/1258681)
58
+ - [@kzk](http://github.com/kzk/) for the [unicorn-worker-killer](https://github.com/kzk/unicorn-worker-killer)
49
59
 
data/lib/worker-killer.rb CHANGED
@@ -1 +1,2 @@
1
- require 'worker_killer'
1
+ require 'worker_killer'
2
+
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorkerKiller
4
- VERSION = '0.0.9'
5
- end
4
+
5
+ VERSION = '0.1.0'
6
+
7
+ end
8
+
@@ -19,7 +19,7 @@ RSpec.describe WorkerKiller::Middleware do
19
19
  end
20
20
 
21
21
  describe WorkerKiller::Middleware::RequestsLimiter do
22
- let(:options){ {reaction: reaction, min: 1111 } }
22
+ let(:options){ { reaction: reaction, min: 1111 } }
23
23
  subject{ described_class.new(app, options) }
24
24
 
25
25
  it 'is expected to be initialized with reaction' do
@@ -31,7 +31,7 @@ RSpec.describe WorkerKiller::Middleware do
31
31
  end
32
32
 
33
33
  describe WorkerKiller::Middleware::OOMLimiter do
34
- let(:options){ {reaction: reaction, min: 2222 } }
34
+ let(:options){ { reaction: reaction, min: 2222 } }
35
35
  subject{ described_class.new(app, options) }
36
36
 
37
37
  it 'is expected to be initialized with reaction' do
@@ -41,6 +41,5 @@ RSpec.describe WorkerKiller::Middleware do
41
41
  expect(subject.limiter.reaction).to eq(reaction)
42
42
  end
43
43
  end
44
-
45
44
  end
46
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_killer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.19836
4
+ version: 0.1.0.19839
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri