Commit 8345ddf6609056455911d4bbd836ac3ccff94bb7

Fixed some minor issues

Commit diff

BUGS.txt

 
1* concurrent_required_instances calculation isn't aware of the fact that there could be concurrent request, but on extension instances. It should only calculate concurrent requests on the same instance
toggle raw diff

lib/dynablaster.rb

 
4040 end
4141
4242 def self.init_kernel_traps
43 $LOG.debug "Setting kernel traps.."
43 $LOG.info "Setting kernel traps.."
4444 Signal.trap("SIGTERM") { Dynablaster.gracefull_shutdown("TERM") }
4545 Signal.trap("SIGINT") { Dynablaster.gracefull_shutdown("INT") }
4646 end
toggle raw diff

lib/handle.rb

 
55class Handle
66
77 def self.load
8 # TODO: Load from config, database etc..
8 # TODO: Load from config, database etc.. Extract app name to App.name to achieve multiple handles for one app
99 h = Handle.new(
10 :name => 'twinity',
10 :name => 'fuboxx',
1111 :host => 'localhost',
12 :host_aliases => ['peter', 'pan'],
12 :host_aliases => ['fuboxx.ruby-labs.de', 'fuboxx.com', 'www.fuboxx.com'],
1313 :extension => Extensions::Mongrel
1414 )
1515
4949 end
5050
5151 def self.shutdown_all_handles
52 $LOG.debug "Unloading active handles.."
5253 @handles.each do |h|
53 h.extension_instances.each { |i| i.stop }
54 h.extension_instances.each do |instance|
55 sleep 5 if instance.state == :loading
56 instance.stop
57 end
5458 end
5559 end
5660end
8989
9090 def ensure_availability(required_instances = 1, force = false)
9191 begin
92 @mutex.synchronize do
92 @mutex.synchronize do
9393 if @extension_instances.size < required_instances
9494 (required_instances - @extension_instances.size).times do
9595 $LOG.debug "#{self.name}: Starting extension instance (#{self.extension}) [#{@extension_instances.size} > #{required_instances}]"
toggle raw diff

lib/tracking.rb

 
3232 request_stats.each { |s| Stat.create_from_stats(app, s[:start], s[:end]) }
3333 app.update_slices
3434 current_crs = concurrent_request_sensitivity_for(app, handle.extension.sensitivity)
35 handle.ensure_availability(current_crs, true)
35 handle.ensure_availability(current_crs, true) if current_crs
3636 end
3737 rescue => e
3838 $LOG.error "ERROR: #{e}"
4343 private
4444
4545 def concurrent_request_sensitivity_for(app, minutes)
46 slices = app.slices.find(:all, :conditions => ["slice_from >= ?", (Time.now - Time.now.sec) - (minutes * 60)])
47 return 1 if slices.blank?
46 plain_minute = (Time.now - Time.now.sec)
47 slices = app.slices.find(:all, :conditions => ["slice_from >= ? AND slice_from < ?", plain_minute - (minutes * 60), plain_minute])
48 return nil if slices.blank?
4849 total_concurrent_requests_for_time_range = 0
4950 slices.each { |s| total_concurrent_requests_for_time_range += s.concurrent_requests}
5051 (total_concurrent_requests_for_time_range / slices.size).ceil
toggle raw diff

marvin/db/development.sqlite3

 
toggle raw diff