daemons 1.2.1 → 1.2.2

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: e59f2e1546ffdb0c31f593a15204e5a027e64392
4
- data.tar.gz: da329109adb90ff065d7ae0e7dd6b0238d83862d
3
+ metadata.gz: 17b967e5ea806bd2c6f2a7def92dd15da0d267fc
4
+ data.tar.gz: 2e2fc8ad98d898e03eff7106a676ec55b9121887
5
5
  SHA512:
6
- metadata.gz: 9e80ab5277dd3607978f6f5ccb23c95088f4dcaec7ecee4059a7649d071bc0c4451f6ece2f415c6900182a19b2e6abd5c8502b59876faa6cac66ec3eefee9eca
7
- data.tar.gz: 0ce93e84a5ef74e07593193bcff94fec8d48687d0e9f976a2d289139ab7c74eb75c9e71811f696a5135eecc8836392ec56b95207982449ad8cd2ed8e19c89376
6
+ metadata.gz: 9de0e91ee02d6e0ecbe2efe6fdac3f116f45320ec54028e37c8404c62faf3a89ad7e0400c561624c69b3ada36150241b621004651658145a7985283bafdbf511
7
+ data.tar.gz: 15d0fbd7a02cd5fd5eeaca7a92353d3ef4a6b804d8e904613e75bc156d55efc2be702299facc216ae7dc96f08b502b93529ddf2097765c5fa821cb00d7dab8fe
data/Releases CHANGED
@@ -1,5 +1,9 @@
1
1
  = Daemons Release History
2
2
 
3
+ == Release 1.2.2: March 17, 2015
4
+
5
+ * fix 100% CPU usage bug when using monitor mode.
6
+
3
7
  == Release 1.2.1: March 10, 2015
4
8
 
5
9
  * increase version number to be able to re-push to rubygems
@@ -152,8 +152,7 @@ module Daemons
152
152
  @pid.pid = Process.pid
153
153
 
154
154
  ENV['DAEMONS_ARGV'] = @controller_argv.join(' ')
155
- # haven't tested yet if this is really passed to the exec'd process...
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: begin - rescue - end around this and exception logging
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.cleanup
427
+ @pid.zap
429
428
  end
430
429
 
431
430
  def zap!
432
- begin; @pid.cleanup; rescue ::Exception; end
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
 
@@ -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
- # options = {}
72
-
73
- # #pp args
61
+
74
62
  @opts.parse(args)
75
63
 
76
64
  @options
@@ -38,7 +38,6 @@ module Daemons
38
38
  # Note that this function should only update <tt>@options</tt> and no other variables.
39
39
  #
40
40
  def setup_options
41
- # @options[:ontop] ||= true
42
41
  end
43
42
 
44
43
  def run
@@ -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
- # sleep(5)
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 "#{e} #{pid}"
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 application
112
+ # We try to remove the pid-files by ourselves, in case the monitor
132
113
  # didn't clean it up.
133
- begin; @pid.cleanup; rescue ::Exception; end
114
+ begin; @pid.zap; rescue ::Exception; end
134
115
  end
135
116
  end
136
117
  end
@@ -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?
@@ -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 # Otherwise an invalid pid file becomes pid 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
@@ -1,3 +1,3 @@
1
1
  module Daemons
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Uehlinger