daemons 1.2.1 → 1.2.2
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.
- checksums.yaml +4 -4
- data/Releases +4 -0
- data/lib/daemons/application.rb +4 -5
- data/lib/daemons/application_group.rb +0 -6
- data/lib/daemons/cmdline.rb +1 -13
- data/lib/daemons/controller.rb +0 -1
- data/lib/daemons/monitor.rb +4 -23
- data/lib/daemons/pid.rb +4 -2
- data/lib/daemons/pidfile.rb +5 -1
- data/lib/daemons/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b967e5ea806bd2c6f2a7def92dd15da0d267fc
|
4
|
+
data.tar.gz: 2e2fc8ad98d898e03eff7106a676ec55b9121887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de0e91ee02d6e0ecbe2efe6fdac3f116f45320ec54028e37c8404c62faf3a89ad7e0400c561624c69b3ada36150241b621004651658145a7985283bafdbf511
|
7
|
+
data.tar.gz: 15d0fbd7a02cd5fd5eeaca7a92353d3ef4a6b804d8e904613e75bc156d55efc2be702299facc216ae7dc96f08b502b93529ddf2097765c5fa821cb00d7dab8fe
|
data/Releases
CHANGED
data/lib/daemons/application.rb
CHANGED
@@ -152,8 +152,7 @@ module Daemons
|
|
152
152
|
@pid.pid = Process.pid
|
153
153
|
|
154
154
|
ENV['DAEMONS_ARGV'] = @controller_argv.join(' ')
|
155
|
-
|
156
|
-
|
155
|
+
|
157
156
|
started
|
158
157
|
Kernel.exec(script, *(@app_argv || []))
|
159
158
|
end
|
@@ -215,7 +214,7 @@ module Daemons
|
|
215
214
|
ARGV.concat @app_argv if @app_argv
|
216
215
|
|
217
216
|
started
|
218
|
-
# TODO:
|
217
|
+
# TODO: exception logging
|
219
218
|
load script
|
220
219
|
end
|
221
220
|
|
@@ -425,11 +424,11 @@ module Daemons
|
|
425
424
|
end
|
426
425
|
|
427
426
|
def zap
|
428
|
-
@pid.
|
427
|
+
@pid.zap
|
429
428
|
end
|
430
429
|
|
431
430
|
def zap!
|
432
|
-
begin; @pid.
|
431
|
+
begin; @pid.zap; rescue ::Exception; end
|
433
432
|
end
|
434
433
|
|
435
434
|
def show_status
|
@@ -6,8 +6,6 @@ module Daemons
|
|
6
6
|
|
7
7
|
attr_reader :monitor
|
8
8
|
|
9
|
-
# attr_reader :controller
|
10
|
-
|
11
9
|
attr_reader :options
|
12
10
|
|
13
11
|
attr_reader :applications
|
@@ -29,11 +27,8 @@ module Daemons
|
|
29
27
|
@script = File.expand_path(options[:script])
|
30
28
|
end
|
31
29
|
|
32
|
-
# @controller = controller
|
33
30
|
@monitor = nil
|
34
31
|
|
35
|
-
# options = controller.options
|
36
|
-
|
37
32
|
@multiple = options[:multiple] || false
|
38
33
|
|
39
34
|
@dir_mode = options[:dir_mode] || :script
|
@@ -42,7 +37,6 @@ module Daemons
|
|
42
37
|
@keep_pid_files = options[:keep_pid_files] || false
|
43
38
|
@no_pidfiles = options[:no_pidfiles] || false
|
44
39
|
|
45
|
-
# @applications = find_applications(pidfile_dir())
|
46
40
|
@applications = []
|
47
41
|
end
|
48
42
|
|
data/lib/daemons/cmdline.rb
CHANGED
@@ -9,10 +9,6 @@ module Daemons
|
|
9
9
|
@opts = OptionParser.new do |opts|
|
10
10
|
opts.banner = ''
|
11
11
|
|
12
|
-
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
13
|
-
# @options[:verbose] = v
|
14
|
-
# end
|
15
|
-
|
16
12
|
opts.on('-t', '--ontop', 'Stay on top (does not daemonize)') do |t|
|
17
13
|
@options[:ontop] = t
|
18
14
|
end
|
@@ -25,16 +21,11 @@ module Daemons
|
|
25
21
|
@options[:no_wait] = t
|
26
22
|
end
|
27
23
|
|
28
|
-
# opts.separator ""
|
29
|
-
# opts.separator "Specific options:"
|
30
|
-
|
31
24
|
opts.separator ''
|
32
25
|
opts.separator 'Common options:'
|
33
26
|
|
34
27
|
# No argument, shows at tail. This will print an options summary
|
35
28
|
opts.on_tail('-h', '--help', 'Show this message') do
|
36
|
-
# puts opts
|
37
|
-
# @usage =
|
38
29
|
controller.print_usage
|
39
30
|
|
40
31
|
exit
|
@@ -62,15 +53,12 @@ END
|
|
62
53
|
end
|
63
54
|
end
|
64
55
|
|
65
|
-
#
|
66
56
|
# Return a hash describing the options.
|
67
57
|
#
|
68
58
|
def parse(args)
|
69
59
|
# The options specified on the command line will be collected in *options*.
|
70
60
|
# We set default values here.
|
71
|
-
|
72
|
-
|
73
|
-
# #pp args
|
61
|
+
|
74
62
|
@opts.parse(args)
|
75
63
|
|
76
64
|
@options
|
data/lib/daemons/controller.rb
CHANGED
data/lib/daemons/monitor.rb
CHANGED
@@ -49,14 +49,10 @@ module Daemons
|
|
49
49
|
Process.detach(fork { a.start(restart = true) })
|
50
50
|
|
51
51
|
sleep(5)
|
52
|
-
|
53
|
-
# application_group.setup
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
|
-
|
58
|
-
# application_group.setup
|
59
|
-
# sleep(30)
|
55
|
+
sleep(30)
|
60
56
|
end
|
61
57
|
end
|
62
58
|
private :watch
|
@@ -67,21 +63,6 @@ module Daemons
|
|
67
63
|
|
68
64
|
begin
|
69
65
|
@pid.pid = Process.pid
|
70
|
-
|
71
|
-
# at_exit {
|
72
|
-
# begin; @pid.cleanup; rescue ::Exception; end
|
73
|
-
# }
|
74
|
-
|
75
|
-
# This part is needed to remove the pid-file if the application is killed by
|
76
|
-
# daemons or manually by the user.
|
77
|
-
# Note that the applications is not supposed to overwrite the signal handler for
|
78
|
-
# 'TERM'.
|
79
|
-
#
|
80
|
-
# trap('TERM') {
|
81
|
-
# begin; @pid.cleanup; rescue ::Exception; end
|
82
|
-
# exit
|
83
|
-
# }
|
84
|
-
|
85
66
|
watch(application_group)
|
86
67
|
rescue ::Exception => e
|
87
68
|
begin
|
@@ -124,13 +105,13 @@ module Daemons
|
|
124
105
|
end
|
125
106
|
end
|
126
107
|
rescue ::Exception => e
|
127
|
-
puts "#{
|
108
|
+
puts "exception while trying to stop monitor process #{pid}: #{e}"
|
128
109
|
puts 'deleting pid-file.'
|
129
110
|
end
|
130
111
|
|
131
|
-
# We try to remove the pid-files by ourselves, in case the
|
112
|
+
# We try to remove the pid-files by ourselves, in case the monitor
|
132
113
|
# didn't clean it up.
|
133
|
-
begin; @pid.
|
114
|
+
begin; @pid.zap; rescue ::Exception; end
|
134
115
|
end
|
135
116
|
end
|
136
117
|
end
|
data/lib/daemons/pid.rb
CHANGED
@@ -18,8 +18,6 @@ module Daemons
|
|
18
18
|
return false
|
19
19
|
rescue ::Exception # for example on EPERM (process exists but does not belong to us)
|
20
20
|
return true
|
21
|
-
# rescue Errno::EPERM
|
22
|
-
# return false
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -67,6 +65,10 @@ module Daemons
|
|
67
65
|
# Cleanup method
|
68
66
|
def cleanup
|
69
67
|
end
|
68
|
+
|
69
|
+
# Zap method
|
70
|
+
def zap
|
71
|
+
end
|
70
72
|
|
71
73
|
# Exist? method
|
72
74
|
def exist?
|
data/lib/daemons/pidfile.rb
CHANGED
@@ -99,11 +99,15 @@ module Daemons
|
|
99
99
|
File.delete(filename) if pid == Process.pid
|
100
100
|
end
|
101
101
|
|
102
|
+
def zap
|
103
|
+
File.delete(filename)
|
104
|
+
end
|
105
|
+
|
102
106
|
def pid
|
103
107
|
begin
|
104
108
|
File.open(filename) do |f|
|
105
109
|
p = f.gets.to_i
|
106
|
-
return nil if p == 0
|
110
|
+
return nil if p == 0 # Otherwise an invalid pid file becomes pid 0
|
107
111
|
return p
|
108
112
|
end
|
109
113
|
rescue ::Exception
|
data/lib/daemons/version.rb
CHANGED