Created
May 4, 2012 13:33
-
-
Save jkutner/2594825 to your computer and use it in GitHub Desktop.
Zero-Downtime deploys with JRuby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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