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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08967f54a434d3f2a95afdff4d3012de7e4667f3
4
- data.tar.gz: def0f290d179d0e77d20641773febe003faeefe8
3
+ metadata.gz: 9a49a7093feca6b333dc7da4ddfbb2dea81377ad
4
+ data.tar.gz: 8d3e900efb9ffae760202f7cb1172f3d9567c895
5
5
  SHA512:
6
- metadata.gz: 8207b32bb5fb5775ce32c3e13beca35c959da25fd3c9ffbb212e43e5ab902303c53ff62c126fe5dc3c9a9f2d1bb596fa451710f7e9fd3f7eff2f7c4a34d689bf
7
- data.tar.gz: ccdc7553329447f58460b573c29e585b044acf334ba79a0df553bd05bd9e908c7cd8d877dd660798fcca15bba6de417ce5d54c9190782f04dea06f9fc35f67bc
6
+ metadata.gz: 04b108265d68f1f49659cf82fcdbc80a625f72ceb6973e41ad69c4ebd6434bb8fb22101f0e82229079733b848caa32d107699ff3e97449f81eb975976ab4671b
7
+ data.tar.gz: 54e5d8e69419aa4748d4a7dcb0ad36731cbd03e270148efe3a51124bd6417cc6fe87808229d51feba23f8ebf8f09ec7035f51bfda2a50e06cc261b457f84997f
@@ -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`
@@ -88,7 +88,7 @@ module Daemonic
88
88
  end
89
89
 
90
90
  def cleanup_pid_file
91
- File.unlink(pid_file) if pid_file
91
+ File.unlink(pid_file) if pid_file && File.exist?(pid_file)
92
92
  end
93
93
 
94
94
  def write_pid_file
@@ -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 ||= Logger.new(@options[:log] || STDOUT).tap { |logger|
44
- logger.level = @options[:log_level] || Logger::INFO
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
 
@@ -1,3 +1,3 @@
1
1
  module Daemonic
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-07-28 00:00:00.000000000 Z
11
+ date: 2014-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler