svutil 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/PostInstall.txt +0 -5
- data/lib/svutil.rb +1 -1
- data/lib/svutil/process_manager.rb +32 -25
- metadata +2 -2
data/History.txt
CHANGED
data/PostInstall.txt
CHANGED
data/lib/svutil.rb
CHANGED
@@ -4,8 +4,8 @@ module SVUtil
|
|
4
4
|
Signal.trap("INT") { shutdown }
|
5
5
|
Signal.trap("TERM") { shutdown }
|
6
6
|
if running?
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
54
|
+
redirect_io
|
48
55
|
end
|
49
56
|
|
50
57
|
def redirect_io
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
62
|
+
STDOUT.sync = true
|
63
|
+
rescue Exception
|
57
64
|
begin; STDOUT.reopen('/dev/null'); rescue Exception; end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
end
|
66
|
+
else
|
67
|
+
begin; STDOUT.reopen('/dev/null'); rescue Exception; end
|
68
|
+
end
|
62
69
|
|
63
|
-
|
64
|
-
|
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.
|
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-
|
12
|
+
date: 2009-06-29 00:00:00 +09:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|