Commit 8345ddf6609056455911d4bbd836ac3ccff94bb7
- Date: Wed Apr 02 17:04:47 +0000 2008
- Committer: rubyphunk (treas@dynamicdudes.com)
- Author: rubyphunk (treas@dynamicdudes.com)
- Commit SHA1: 8345ddf6609056455911d4bbd836ac3ccff94bb7
- Tree SHA1: d663ce8c8fbdcb890454e8d1237998df29f29cfa
- lib/tracking.rb 7 ---++++
- marvin/db/development.sqlite3 0
- lib/dynablaster.rb 2 -+
- lib/handle.rb 14 -----+++++++++
- BUGS.txt 1 +
Commit diff
- Diff rendering mode:
- inline
- side by side
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
|   | ||
| 40 | 40 | end |
| 41 | 41 | |
| 42 | 42 | def self.init_kernel_traps |
| 43 | ||
| 43 | $LOG.info "Setting kernel traps.." | |
| 44 | 44 | Signal.trap("SIGTERM") { Dynablaster.gracefull_shutdown("TERM") } |
| 45 | 45 | Signal.trap("SIGINT") { Dynablaster.gracefull_shutdown("INT") } |
| 46 | 46 | end |
| toggle raw diff | ||
lib/handle.rb
|   | ||
| 5 | 5 | class Handle |
| 6 | 6 | |
| 7 | 7 | def self.load |
| 8 | ||
| 8 | # TODO: Load from config, database etc.. Extract app name to App.name to achieve multiple handles for one app | |
| 9 | 9 | h = Handle.new( |
| 10 | ||
| 10 | :name => 'fuboxx', | |
| 11 | 11 | :host => 'localhost', |
| 12 | ||
| 12 | :host_aliases => ['fuboxx.ruby-labs.de', 'fuboxx.com', 'www.fuboxx.com'], | |
| 13 | 13 | :extension => Extensions::Mongrel |
| 14 | 14 | ) |
| 15 | 15 | |
| … | … | |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | def self.shutdown_all_handles |
| 52 | $LOG.debug "Unloading active handles.." | |
| 52 | 53 | @handles.each do |h| |
| 53 | ||
| 54 | h.extension_instances.each do |instance| | |
| 55 | sleep 5 if instance.state == :loading | |
| 56 | instance.stop | |
| 57 | end | |
| 54 | 58 | end |
| 55 | 59 | end |
| 56 | 60 | end |
| … | … | |
| 89 | 89 | |
| 90 | 90 | def ensure_availability(required_instances = 1, force = false) |
| 91 | 91 | begin |
| 92 | ||
| 92 | @mutex.synchronize do | |
| 93 | 93 | if @extension_instances.size < required_instances |
| 94 | 94 | (required_instances - @extension_instances.size).times do |
| 95 | 95 | $LOG.debug "#{self.name}: Starting extension instance (#{self.extension}) [#{@extension_instances.size} > #{required_instances}]" |
| toggle raw diff | ||
lib/tracking.rb
|   | ||
| 32 | 32 | request_stats.each { |s| Stat.create_from_stats(app, s[:start], s[:end]) } |
| 33 | 33 | app.update_slices |
| 34 | 34 | current_crs = concurrent_request_sensitivity_for(app, handle.extension.sensitivity) |
| 35 | ||
| 35 | handle.ensure_availability(current_crs, true) if current_crs | |
| 36 | 36 | end |
| 37 | 37 | rescue => e |
| 38 | 38 | $LOG.error "ERROR: #{e}" |
| … | … | |
| 43 | 43 | private |
| 44 | 44 | |
| 45 | 45 | def concurrent_request_sensitivity_for(app, minutes) |
| 46 | ||
| 47 | ||
| 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? | |
| 48 | 49 | total_concurrent_requests_for_time_range = 0 |
| 49 | 50 | slices.each { |s| total_concurrent_requests_for_time_range += s.concurrent_requests} |
| 50 | 51 | (total_concurrent_requests_for_time_range / slices.size).ceil |
| toggle raw diff | ||
marvin/db/development.sqlite3
|   | ||
| toggle raw diff | ||
