lib/gumdrop/server.rb in gumdrop-1.1.0 vs lib/gumdrop/server.rb in gumdrop-1.1.1
- old
+ new
@@ -5,15 +5,19 @@
module Gumdrop
STATIC_ASSETS= %w(.jpg .jpe .jpeg .gif .ico .png .swf)
+ class RenderPool
+ end
+
class Server < Sinatra::Base
include Util::Loggable
site= Gumdrop.site
scan_count= 0
+ gc_after= 3
unless site.nil?
site.scan true
scan_count += 1
last_scan= Time.now.to_i
@@ -39,29 +43,30 @@
unless static_asset file_path
since_last_build= Time.now.to_i - last_scan
# site.report "!>!>>>>> since_last_build: #{since_last_build}"
if since_last_build > site.config.server_timeout
- log.info "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout})"
+ log.info "[#{$$}] Rebuilding from Source (#{since_last_build} > #{site.config.server_timeout}) #{scan_count % gc_after}"
+ last_scan= Time.now.to_i
site.scan true
scan_count += 1
- last_scan= Time.now.to_i
- if scan_count % 50 == 0
+ log.info "[#{$$}] Finished re-scan - #{ Time.now.to_i - last_scan }s"
+ if scan_count % gc_after == 0
log.info "<* Initiating Garbage Collection *>"
GC.start
end
end
end
if site.contents.has_key? file_path
- renderer= Renderer.new
content= site.contents[file_path]
content_type :css if content.ext == '.css' # Meh?
content_type :js if content.ext == '.js' # Meh?
content_type :xml if content.ext == '.xml' # Meh?
unless content.binary?
log.info "[#{$$}] *Dynamic: #{file_path} (#{content.ext})"
begin
+ renderer= Renderer.new
content= renderer.draw content
rescue => ex
log.error "ERROR!"
log.error ex
$stderr.puts "\n\n --------- \n Error! (#{content.uri}) #{ex}\n --------- \n\n"
\ No newline at end of file