daemonic 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/worker.feature +2 -2
- data/lib/daemonic/daemon.rb +1 -1
- data/lib/daemonic/producer.rb +17 -4
- data/lib/daemonic/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: 9a49a7093feca6b333dc7da4ddfbb2dea81377ad
|
4
|
+
data.tar.gz: 8d3e900efb9ffae760202f7cb1172f3d9567c895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b108265d68f1f49659cf82fcdbc80a625f72ceb6973e41ad69c4ebd6434bb8fb22101f0e82229079733b848caa32d107699ff3e97449f81eb975976ab4671b
|
7
|
+
data.tar.gz: 54e5d8e69419aa4748d4a7dcb0ad36731cbd03e270148efe3a51124bd6417cc6fe87808229d51feba23f8ebf8f09ec7035f51bfda2a50e06cc261b457f84997f
|
data/features/worker.feature
CHANGED
@@ -25,13 +25,13 @@ Feature: Worker
|
|
25
25
|
Daemonic.run { MyWorker.new }
|
26
26
|
"""
|
27
27
|
|
28
|
-
When I run `./worker start --daemonize --pid tmp/worker.pid`
|
28
|
+
When I run `./worker start --daemonize --pid tmp/worker.pid --log test.log`
|
29
29
|
Then the exit status should be 0
|
30
30
|
|
31
31
|
When I run `./worker status --pid tmp/worker.pid`
|
32
32
|
Then the exit status should be 0
|
33
33
|
|
34
|
-
When I run `./worker restart --pid tmp/worker.pid`
|
34
|
+
When I run `./worker restart --pid tmp/worker.pid --log test.log`
|
35
35
|
Then the exit status should be 0
|
36
36
|
|
37
37
|
When I run `./worker stop --pid tmp/worker.pid`
|
data/lib/daemonic/daemon.rb
CHANGED
data/lib/daemonic/producer.rb
CHANGED
@@ -13,8 +13,21 @@ module Daemonic
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
+
|
16
17
|
logger.info "Starting producer with #{concurrency} consumer threads."
|
17
18
|
|
19
|
+
at_exit {
|
20
|
+
last_error = $!
|
21
|
+
if last_error
|
22
|
+
msg = "Shutting down: #{last_error.inspect}\n#{last_error.backtrace.join("\n")}"
|
23
|
+
logger.fatal msg
|
24
|
+
$stdout.puts msg
|
25
|
+
else
|
26
|
+
logger.fatal "Shutting down"
|
27
|
+
$stdout.puts "Shutting down"
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
18
31
|
Signal.trap("INT") { stop }
|
19
32
|
Signal.trap("TERM") { stop }
|
20
33
|
|
@@ -31,8 +44,6 @@ module Daemonic
|
|
31
44
|
|
32
45
|
producer.join
|
33
46
|
|
34
|
-
logger.info { "Shutting down" }
|
35
|
-
|
36
47
|
end
|
37
48
|
|
38
49
|
def stop
|
@@ -40,8 +51,10 @@ module Daemonic
|
|
40
51
|
end
|
41
52
|
|
42
53
|
def logger
|
43
|
-
@logger ||=
|
44
|
-
|
54
|
+
@logger ||= @options.fetch(:logger) {
|
55
|
+
Logger.new(@options[:log] || STDOUT).tap { |logger|
|
56
|
+
logger.level = @options[:log_level] || Logger::INFO
|
57
|
+
}
|
45
58
|
}
|
46
59
|
end
|
47
60
|
|
data/lib/daemonic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemonic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|