svutil 0.0.10 → 0.0.11

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.
data/lib/svutil.rb CHANGED
@@ -6,5 +6,5 @@ require 'svutil/log'
6
6
  require 'svutil/process_manager'
7
7
 
8
8
  module SVUtil
9
- VERSION = '0.0.10'
9
+ VERSION = '0.0.11'
10
10
  end
@@ -2,9 +2,9 @@ module SVUtil
2
2
  class ProcessManager
3
3
  def initialize(klass)
4
4
  # TODO: Add ability for users to specify these signals
5
- Signal.trap("INT") { shutdown('Interupted') }
6
- Signal.trap("TERM") { shutdown('Terminated') }
7
- Signal.trap("PIPE") { shutdown('Broken Pipe') }
5
+ Signal.trap("INT") { shutdown('Interupted', 1) }
6
+ Signal.trap("TERM") { shutdown('Terminated', 2) }
7
+ Signal.trap("PIPE") { shutdown('Broken Pipe', 4) }
8
8
  if running?
9
9
  STDERR.puts "There is already a '#{$0}' process running"
10
10
  exit 1
@@ -18,22 +18,28 @@ module SVUtil
18
18
  def start
19
19
  begin
20
20
  @server_instance.run
21
- rescue
22
- Log.error $!
23
- Log.error $!.backtrace if SVUtil::config.trace
24
- shutdown("Process Completed with Error")
25
- exit 1
21
+ rescue SystemExit => e
22
+ shutdown("System Exited")
23
+ rescue Exception => e
24
+ Log.error(e.message)
25
+ Log.error(e.backtrace.join("\n")) if SVUtil::config.trace
26
+ shutdown("Process Completed with Error", 1)
26
27
  end
27
28
  shutdown("Process Completed")
28
- exit 0
29
29
  end
30
30
 
31
31
  private
32
- def shutdown(reason = nil)
32
+ def shutdown(reason = nil, exit_code = 0)
33
33
  Log.info "Shutting Down (#{reason})"
34
- @server_instance.shutdown if @server_instance.respond_to?(:shutdown)
34
+ begin
35
+ @server_instance.shutdown if @server_instance.respond_to?(:shutdown)
36
+ rescue => e
37
+ Log.error("Shutdown Callback threw error: #{e.message}")
38
+ Log.error("Shutdown Callback threw error: #{e.backtrace}") if SVUtil::config.trace
39
+ Log.info("Shuting down anyway")
40
+ end
35
41
  remove_pid_file
36
- exit 0
42
+ exit exit_code
37
43
  end
38
44
 
39
45
  def running?
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Draper
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-19 00:00:00 +09:30
17
+ date: 2010-07-24 00:00:00 +09:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -40,9 +40,9 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 2
43
- - 4
43
+ - 6
44
44
  - 0
45
- version: 2.4.0
45
+ version: 2.6.0
46
46
  type: :development
47
47
  version_requirements: *id002
48
48
  description: A simple managed process builder for Ruby projects