Skip to content

Instantly share code, notes, and snippets.

@jkutner
Created May 4, 2012 13:33
Show Gist options
  • Save jkutner/2594825 to your computer and use it in GitHub Desktop.
Save jkutner/2594825 to your computer and use it in GitHub Desktop.
Zero-Downtime deploys with JRuby
def check_monitors
@contexts.each do |c|
#...
c[:context] = create_takeover(c)
Thread.new { c[:context].start }
end
end
def create_takeover(c)
web_app = c[:app]
old_context = c[:context]
context = Trinidad::Tomcat::StandardContext.new
context.name = rand.to_s
context.path = old_context.path
context.doc_base = web_app.web_app_dir
context.add_lifecycle_listener Trinidad::Tomcat::Tomcat::DefaultWebXmlListener.new
config = Trinidad::Tomcat::ContextConfig.new
config.default_web_xml = 'org/apache/catalina/startup/NO_DEFAULT_XML'
context.add_lifecycle_listener config
Trinidad::Extensions.configure_webapp_extensions(web_app.extensions, @tomcat, context)
web_app.generate_class_loader
context.add_lifecycle_listener(web_app.define_lifecycle)
context.add_lifecycle_listener(Trinidad::Lifecycle::Takeover.new(c))
old_context.parent.add_child context
context
end
application:
root: /path/to/myapp.knob
web:
context: myapp-v2/
environment:
RAILS_ENV: production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment