sponges 1.2.0 → 1.2.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/README.md +14 -12
- data/lib/sponges/alive.rb +2 -0
- data/lib/sponges/listener.rb +5 -3
- data/lib/sponges/version.rb +1 -1
- metadata +26 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0148b0f41512aee87d7637ffde219add1b57041
|
4
|
+
data.tar.gz: 9f4c5659fe1817aecf1fb054118c829ad672e51c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa957168031528c0ae92a12145a1df9bae034c047a9eb49aa496e32a6dccba41bdcb46a934359427d4d8813acb18905bdf33d6b46841033c5decde1f76e243f
|
7
|
+
data.tar.gz: 42b9af23f6e4317d1290718178572baa2be8c24f150641ad6689a040052d2142bf11e385e2ee5c7f495bfff701743bd82d3f7ca50a63e2444ba5fe888d316494
|
data/README.md
CHANGED
@@ -4,13 +4,15 @@
|
|
4
4
|
Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/AF83/sponges)
|
5
5
|
[](http://badge.fury.io/rb/sponges)
|
7
|
+
[](https://travis-ci.org/AF83/sponges)
|
7
9
|
|
8
|
-
When I build workers, I want them to be much like an army of
|
9
|
-
stressed and eager to work. `sponges` helps you with building this army of sponges,
|
10
|
-
|
11
|
-
stressed and eager to work would still be your job :)
|
10
|
+
When I build workers, I want them to be much like an army of Sponge Bobs: always
|
11
|
+
stressed, and eager to work. `sponges` helps you with building this army of sponges,
|
12
|
+
controlling them, and well, eventually killing them gracefully. Hum, making them
|
13
|
+
stressed and eager to work would still be your job. :)
|
12
14
|
|
13
|
-
Basically,
|
15
|
+
Basically, Sponges is a ruby supervisor that forks processes and controls their
|
14
16
|
execution and termination. For example, the following will start a supervision
|
15
17
|
daemon and 8 processes of "a_worker":
|
16
18
|
|
@@ -35,7 +37,7 @@ You may use bundler. In this case, add it to your `Gemfile`:
|
|
35
37
|
gem "sponges"
|
36
38
|
```
|
37
39
|
|
38
|
-
|
40
|
+
Then, run `bundle install`.
|
39
41
|
|
40
42
|
## Usage
|
41
43
|
|
@@ -110,7 +112,7 @@ Start 8 instances of the worker and daemonize them:
|
|
110
112
|
ruby example.rb start -d -s 8 # By default, size equals cpu core's size.
|
111
113
|
```
|
112
114
|
|
113
|
-
|
115
|
+
Restart gracefully 4 instances of the worker, with a timeout of 3 seconds, and
|
114
116
|
daemonize them:
|
115
117
|
``` bash
|
116
118
|
ruby example.rb restart -g -s 4 -t 3
|
@@ -133,7 +135,7 @@ ruby example.rb stop -g -t 5
|
|
133
135
|
|
134
136
|
In this case, you will have to trap the `HUP` signal, and handle a clean stop
|
135
137
|
from each workers. The point is to wait for a task to be done before quitting. A
|
136
|
-
timeout can be
|
138
|
+
timeout can be specified with the `-t` option. When this timeout is hit, the
|
137
139
|
process is killed.
|
138
140
|
|
139
141
|
Increment worker's pool size :
|
@@ -148,7 +150,7 @@ ruby example.rb decrement # will remove a worker from the pool.
|
|
148
150
|
|
149
151
|
## HTTP supervision
|
150
152
|
|
151
|
-
|
153
|
+
Sponges provides an HTTP interface to supervise the pool's activity, and expose
|
152
154
|
pids. HTTP supervision can be enabled in the configuration:
|
153
155
|
|
154
156
|
|
@@ -158,8 +160,8 @@ Sponges.configure do |config|
|
|
158
160
|
end
|
159
161
|
```
|
160
162
|
|
161
|
-
By default,
|
162
|
-
|
163
|
+
By default, Sponges listens on port 5032, and responds with JSON. Here is a
|
164
|
+
sample:
|
163
165
|
|
164
166
|
``` javascript
|
165
167
|
{
|
@@ -202,7 +204,7 @@ example of response:
|
|
202
204
|
|
203
205
|
## Acknowledgements
|
204
206
|
|
205
|
-
|
207
|
+
Sponges would not have been the same without [Jesse
|
206
208
|
Storimer](https://github.com/jstorimer) and his awesome book about
|
207
209
|
[Unix](http://workingwithunixprocesses.com/).
|
208
210
|
|
data/lib/sponges/alive.rb
CHANGED
data/lib/sponges/listener.rb
CHANGED
@@ -22,9 +22,11 @@ module Sponges
|
|
22
22
|
response = Response.new(supervisor).to_json
|
23
23
|
connection.write headers(response)
|
24
24
|
connection.write response
|
25
|
-
connection.
|
26
|
-
|
27
|
-
|
25
|
+
connection.close_write
|
26
|
+
connection.close_read
|
27
|
+
rescue SystemCallError
|
28
|
+
# Resist to system errors when closing or writing to a socket that is not
|
29
|
+
# opened.
|
28
30
|
end
|
29
31
|
|
30
32
|
def headers(response)
|
data/lib/sponges/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sponges
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chatgris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: boson
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: machine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.10.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.10.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: When I build workers, I want them to be like an army of spongebobs, always
|
56
70
|
stressed and eager to work. sponges helps you build this army of sponges, to control
|
57
71
|
them, and, well, to kill them gracefully. Making them stressed and eager to work
|
@@ -87,18 +101,19 @@ require_paths:
|
|
87
101
|
- lib
|
88
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
103
|
requirements:
|
90
|
-
- -
|
104
|
+
- - ">="
|
91
105
|
- !ruby/object:Gem::Version
|
92
106
|
version: '0'
|
93
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- -
|
109
|
+
- - ">="
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: '0'
|
98
112
|
requirements: []
|
99
113
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.2.2
|
101
115
|
signing_key:
|
102
116
|
specification_version: 4
|
103
117
|
summary: Turn any ruby object to a daemon controlling an army of sponges.
|
104
118
|
test_files: []
|
119
|
+
has_rdoc:
|