rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob aaa11c930c95fa3b370f64b8c1169930b1da4022 459 bytes (raw)
$ git show HEAD:t/large-file-response.ru	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 
# lib-large-file-response will stop running if we're not on Linux here
use Rack::ContentLength
use Rack::ContentType
map "/rss" do
  run lambda { |env|
    # on Linux, this is in kilobytes
    GC.start if GC.respond_to?(:start)
    ::File.read("/proc/self/status") =~ /^VmRSS:\s+(\d+)/
    [ 200, {}, [ ($1.to_i * 1024).to_s ] ]
  }
end
map "/pid" do
  run lambda { |env| [ 200, {}, [ "#{Process.pid}\n" ] ] }
end
map "/" do
  run Rack::File.new(Dir.pwd)
end

git clone https://yhbt.net/rainbows.git