foreverb 0.3.0.f → 0.3.0.g

Sign up to get free protection for your applications and to get access to all the features.
data/lib/forever/base.rb CHANGED
@@ -85,19 +85,24 @@ module Forever
85
85
  # Invoke our before :all filters
86
86
  filters[:before][:all].each { |block| safe_call(block) }
87
87
 
88
+ # Store pids of childs
89
+ pids = []
90
+
88
91
  # Start deamons
89
92
  until stopping?
90
93
  current_queue = 1
94
+
91
95
  jobs.each do |job|
92
96
  next unless job.time?(Time.now)
93
97
  if queue && current_queue > queue
94
- puts "\n\nThe queue limit has been exceeded. You are using #{current_queue} of #{queue} slots.\n\n"
98
+ puts "\n\nThe queue limit of #{queue} has been exceeded.\n\n"
95
99
  on_limit_exceeded ? on_limit_exceeded.call : sleep(60)
96
100
  break
97
101
  end
98
102
  if forking
99
103
  begin
100
- Process.fork { job_call(job) }
104
+ GC.start
105
+ pids << Process.fork { job_call(job) }
101
106
  rescue Errno::EAGAIN
102
107
  puts "\n\nWait all processes since os cannot create a new one\n\n"
103
108
  Process.waitall
@@ -107,6 +112,17 @@ module Forever
107
112
  end
108
113
  current_queue += 1
109
114
  end
115
+
116
+ # Detach zombies, our ps will be happier
117
+ pids.each do |p|
118
+ begin
119
+ Process.getpgid(p)
120
+ rescue Errno::ESRCH
121
+ pids.delete(p)
122
+ Process.detach(p)
123
+ end
124
+ end
125
+
110
126
  sleep 0.5
111
127
  end
112
128
 
@@ -229,7 +245,7 @@ module Forever
229
245
  ##
230
246
  # Remove the daemon from the config file
231
247
  #
232
- def remove
248
+ def remove
233
249
  print "[\e[90m%s\e[0m] Removed the daemon from the config " % name
234
250
  config_was = File.exist?(FOREVER_PATH) ? YAML.load_file(FOREVER_PATH) : []
235
251
  config_was.delete_if { |conf| conf[:file] == file }
@@ -1,3 +1,3 @@
1
1
  module Forever
2
- VERSION = "0.3.0.f" unless defined?(Forever::VERSION)
2
+ VERSION = "0.3.0.g" unless defined?(Forever::VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreverb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 60
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 0
10
- - f
11
- version: 0.3.0.f
10
+ - g
11
+ version: 0.3.0.g
12
12
  platform: ruby
13
13
  authors:
14
14
  - DAddYE
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-09 00:00:00 +01:00
20
- default_executable:
19
+ date: 2012-01-24 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: thor
@@ -77,7 +76,6 @@ files:
77
76
  - spec/cli_spec.rb
78
77
  - spec/foreverb_spec.rb
79
78
  - spec/spec_helper.rb
80
- has_rdoc: true
81
79
  homepage: https://github.com/daddye/forever
82
80
  licenses: []
83
81
 
@@ -109,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
107
  requirements: []
110
108
 
111
109
  rubyforge_project: foreverb
112
- rubygems_version: 1.6.2
110
+ rubygems_version: 1.8.15
113
111
  signing_key:
114
112
  specification_version: 3
115
113
  summary: Small daemon framework for ruby
@@ -117,3 +115,4 @@ test_files:
117
115
  - spec/cli_spec.rb
118
116
  - spec/foreverb_spec.rb
119
117
  - spec/spec_helper.rb
118
+ has_rdoc: