svutil 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,3 +2,7 @@
2
2
 
3
3
  * 1 major enhancement:
4
4
  * Initial release
5
+
6
+ == 0.0.2 2009-06-29
7
+ * Fix problems with handling errors
8
+ * Ensure clean exits
@@ -1,7 +1,2 @@
1
1
 
2
2
  For more information on svutil, see http://svutil.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
@@ -6,5 +6,5 @@ require 'svutil/log'
6
6
  require 'svutil/process_manager'
7
7
 
8
8
  module SVUtil
9
- VERSION = '0.0.1'
9
+ VERSION = '0.0.2'
10
10
  end
@@ -4,8 +4,8 @@ module SVUtil
4
4
  Signal.trap("INT") { shutdown }
5
5
  Signal.trap("TERM") { shutdown }
6
6
  if running?
7
- STDERR.puts "There is already a '#{$0}' process running"
8
- exit 1
7
+ STDERR.puts "There is already a '#{$0}' process running"
8
+ exit 1
9
9
  end
10
10
  daemonize if config.daemon
11
11
  write_pid_file
@@ -13,7 +13,14 @@ module SVUtil
13
13
  end
14
14
 
15
15
  def start
16
- @klass.new.run
16
+ begin
17
+ @klass.new.run
18
+ rescue
19
+ puts $!
20
+ ensure
21
+ remove_pid_file
22
+ exit 1
23
+ end
17
24
  end
18
25
 
19
26
  private
@@ -24,44 +31,44 @@ module SVUtil
24
31
  end
25
32
 
26
33
  def running?
27
- pid_file = config.pid_file
28
- return false unless pid_file
29
- File.exist?(pid_file)
34
+ pid_file = config.pid_file
35
+ return false unless pid_file
36
+ File.exist?(pid_file)
30
37
  end
31
38
 
32
39
  def write_pid_file
33
- pid_file = config.pid_file
34
- return unless pid_file
35
- File.open(pid_file, "w") { |f| f.write(Process.pid) }
36
- File.chmod(0644, pid_file)
40
+ pid_file = config.pid_file
41
+ return unless pid_file
42
+ File.open(pid_file, "w") { |f| f.write(Process.pid) }
43
+ File.chmod(0644, pid_file)
37
44
  end
38
45
 
39
46
  def remove_pid_file
40
- pid_file = config.pid_file
41
- return unless pid_file
42
- File.unlink(pid_file) if File.exists?(pid_file)
47
+ pid_file = config.pid_file
48
+ return unless pid_file
49
+ File.unlink(pid_file) if File.exists?(pid_file)
43
50
  end
44
51
 
45
52
  def daemonize
46
53
  fork and exit
47
- redirect_io
54
+ redirect_io
48
55
  end
49
56
 
50
57
  def redirect_io
51
- begin; STDIN.reopen('/dev/null'); rescue Exception; end
52
- if config.log_file
53
- begin
58
+ begin; STDIN.reopen('/dev/null'); rescue Exception; end
59
+ if config.log_file
60
+ begin
54
61
  STDOUT.reopen(config.log_file, "a")
55
- STDOUT.sync = true
56
- rescue Exception
62
+ STDOUT.sync = true
63
+ rescue Exception
57
64
  begin; STDOUT.reopen('/dev/null'); rescue Exception; end
58
- end
59
- else
60
- begin; STDOUT.reopen('/dev/null'); rescue Exception; end
61
- end
65
+ end
66
+ else
67
+ begin; STDOUT.reopen('/dev/null'); rescue Exception; end
68
+ end
62
69
 
63
- begin; STDERR.reopen(STDOUT); rescue Exception; end
64
- STDERR.sync = true
70
+ begin; STDERR.reopen(STDOUT); rescue Exception; end
71
+ STDERR.sync = true
65
72
  end
66
73
  end
67
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - FIXME full name
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-22 00:00:00 +09:30
12
+ date: 2009-06-29 00:00:00 +09:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency