resque-worker-killer 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +16 -2
- data/example/my_job.rb +3 -3
- data/lib/resque/plugins/worker_killer.rb +1 -1
- data/lib/resque/plugins/worker_killer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a23bdc379d3a62bce0e338cf942521a66cb9c8
|
4
|
+
data.tar.gz: c17c3e400a02b970e191d6fc5dbe3637fa6d19e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffce9a6ea932cf1aed36a2b309b883543cd6e79d1233f99f61b6dfe9cdf7c2104f1bab409692c07e878e28273349c6019e9450c9c38b745b84f4d85af6ad911c
|
7
|
+
data.tar.gz: 0c18a8d59ac8ee941f4ecfaaa656980dc29e59f8d97dcc9df5b8c410b865515f1cfcb74b0edf0ebf63cbaec37c5b69527d05b6199bb21fceaf47e904225e2993
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
resque-worker-killer gem provides automatic kill of a forked child of Resque worker based on process memory size (RSS) not to exceed the maximum allowed memory size.
|
6
6
|
|
7
|
+
The name was inspired by [unicorn-worker-killer](https://github.com/kzk/unicorn-worker-killer) :-p
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -49,17 +51,29 @@ class MyJob
|
|
49
51
|
end
|
50
52
|
```
|
51
53
|
|
52
|
-
|
54
|
+
### TERM_CHILD=1
|
55
|
+
|
56
|
+
Resque requires to set `TERM_CHILD` environment variable to accept killing a forked child with SIGTERM.
|
53
57
|
|
54
58
|
```
|
55
59
|
$ TERM_CHILD=1 bundle exec rake resque:work
|
56
60
|
```
|
61
|
+
Thus,
|
62
|
+
|
63
|
+
* Without `TERM_CHILD=1`, set `@worker_killter_max_term = 0` to send SIGKILL immediately
|
64
|
+
* With `TERM_CHILD=1`, set `@worker_killer_max_term > 0` to try SIGTERM first, then SIGKILL
|
65
|
+
|
66
|
+
With `TERM_CHILD=1`, `Resque::TermException` is raised if a forked child is killed by SIGTERM.
|
67
|
+
|
68
|
+
## Options
|
57
69
|
|
58
70
|
Options are:
|
59
71
|
|
60
72
|
* `@worker_killer_monitor_interval`: Monotring interval to check RSS size (default: 1.0 sec)
|
61
73
|
* `@worker_killer_mem_limit`: RSS usage limit, in killobytes (default: 300MB)
|
62
|
-
* `@worker_killer_max_term`: Try kiling child process with SIGTERM in
|
74
|
+
* `@worker_killer_max_term`: Try kiling child process with SIGTERM in `max_term` times, then SIGKILL if it still does not die.
|
75
|
+
Please note that setting `TERM_CHILD` environment variable is required to accept killing the child with SIGTERM.
|
76
|
+
The default is, 10 with `TERM_CHILD=1`, 0 without `TERM_CHILD=1`.
|
63
77
|
* `@worker_killer_verbose`: Verbose log
|
64
78
|
* `@worker_killer_logger`: Logger instance (default: Resque.logger)
|
65
79
|
|
data/example/my_job.rb
CHANGED
@@ -8,15 +8,15 @@ class MyJob
|
|
8
8
|
extend Resque::Plugins::WorkerKiller
|
9
9
|
@worker_killer_monitor_interval = 0.5 # sec
|
10
10
|
@worker_killer_mem_limit = 10_000 # KB
|
11
|
-
@worker_killer_max_term = 10
|
11
|
+
@worker_killer_max_term = (ENV['TERM_CHILD'] ? 10 : 0)
|
12
12
|
@worker_killer_verbose = true
|
13
13
|
@worker_killer_logger = ::Logger.new(STDOUT)
|
14
14
|
|
15
15
|
def self.perform(params)
|
16
16
|
puts 'started'
|
17
|
-
sleep
|
17
|
+
sleep 1
|
18
18
|
str = 'a' * 10 * 1024 * 1024
|
19
|
-
sleep
|
19
|
+
sleep 3
|
20
20
|
puts 'finished'
|
21
21
|
rescue Resque::TermException => e # env TERM_CHILD=1
|
22
22
|
puts 'terminated'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-worker-killer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resque
|