quebert 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/quebert/version.rb +1 -1
- data/lib/quebert/worker.rb +20 -5
- metadata +4 -4
data/lib/quebert/version.rb
CHANGED
data/lib/quebert/worker.rb
CHANGED
@@ -10,18 +10,33 @@ module Quebert
|
|
10
10
|
|
11
11
|
# Start the worker backend and intercept exceptions if a handler is provided
|
12
12
|
def start
|
13
|
-
Signal.trap('TERM'){
|
14
|
-
|
13
|
+
Signal.trap('TERM') { safe_stop }
|
14
|
+
Signal.trap('INT') { safe_stop }
|
15
|
+
|
15
16
|
logger.info "Worker started with #{backend.class.name} backend\n"
|
16
|
-
while controller = backend.reserve do
|
17
|
+
while @controller = backend.reserve do
|
17
18
|
begin
|
18
|
-
controller.perform
|
19
|
+
@controller.perform
|
19
20
|
rescue Exception => e
|
20
21
|
exception_handler ? exception_handler.call(e) : raise(e)
|
21
|
-
end
|
22
|
+
end
|
23
|
+
@controller = nil
|
24
|
+
|
25
|
+
stop if @terminate_sent
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
29
|
+
def safe_stop
|
30
|
+
if @terminate_sent
|
31
|
+
logger.info "Ok! I get the point. Shutting down immediately."
|
32
|
+
stop
|
33
|
+
else
|
34
|
+
logger.info "Finishing current job then shutting down."
|
35
|
+
@terminate_sent = true
|
36
|
+
stop unless @controller
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
25
40
|
def stop
|
26
41
|
logger.info "Worker stopping\n"
|
27
42
|
exit 0
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quebert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brad Gessler
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date:
|
20
|
+
date: 2012-03-09 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|