Sha256: 8d5017fa19afe379fdf9e2900e441e427f565ba18284fa636eb78aca63c21ad6
Contents?: true
Size: 811 Bytes
Versions: 1
Compression:
Stored size: 811 Bytes
Contents
module Tennpipes module Reloader ## # This class acts as a Rack middleware to be added to the application stack. # This middleware performs a check and reload for source files at the start # of each request, but also respects a specified cool down time # during which no further action will be taken. # class Rack def initialize(app, cooldown=1) @app = app @cooldown = cooldown @last = (Time.now - cooldown) end # Invoked in order to perform the reload as part of the request stack. def call(env) if @cooldown && Time.now > @last + @cooldown Thread.list.size > 1 ? Thread.exclusive { Tennpipes.reload! } : Tennpipes.reload! @last = Time.now end @app.call(env) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tennpipes-base-3.6.6 | lib/tennpipes-base/reloader/rack.rb |