Sha256: c9bb06ab4c48940e13087aa889d11fa01cac26cf07561f22899427099065fd07
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module Trinidad module Lifecycle class Host include Trinidad::Tomcat::LifecycleListener attr_reader :contexts def initialize(*contexts) @contexts = contexts end def lifecycleEvent(event) host = event.lifecycle case event.type when Trinidad::Tomcat::Lifecycle::BEFORE_START_EVENT init_monitors when Trinidad::Tomcat::Lifecycle::PERIODIC_EVENT check_monitors end end def init_monitors @contexts.each do |c| monitor = c[:monitor] opts = File.exist?(monitor) ? 'r' : 'w+' unless File.exist?(dir = File.dirname(monitor)) Dir.mkdir dir end file = File.new(monitor, opts) c[:mtime] = file.mtime end end def check_monitors @contexts.each do |c| # double check monitor, capistrano removes it temporarily sleep(0.5) unless File.exist?(c[:monitor]) next unless File.exist?(c[:monitor]) if (mtime = File.mtime(c[:monitor])) > c[:mtime] c[:mtime] = mtime c[:context].reload end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trinidad-1.1.1 | lib/trinidad/lifecycle/lifecycle_listener_host.rb |
trinidad-1.1.0 | lib/trinidad/lifecycle/lifecycle_listener_host.rb |