lib/trinidad/server.rb in trinidad-1.1.1 vs lib/trinidad/server.rb in trinidad-1.2.0

- old
+ new

@@ -53,11 +53,11 @@ apps.flatten.compact end def load_host_monitor(apps) - @tomcat.host.add_lifecycle_listener(Trinidad::Lifecycle::Host.new(*apps)) + @tomcat.host.add_lifecycle_listener(Trinidad::Lifecycle::Host.new(@tomcat, *apps)) end def create_from_web_apps if @config[:web_apps] @config[:web_apps].map do |name, app_config| @@ -81,13 +81,10 @@ name = File.basename(path) app_config = { :context_path => (name == 'default' ? '' : "/#{name.to_s}"), :web_app_dir => File.expand_path(path) } - if File.directory?(path) && File.exist?(File.expand_path('config.ru', path)) - app_config[:rackup] = 'config.ru' - end create_web_app(app_config) end end end @@ -98,14 +95,13 @@ app_context = @tomcat.addWebapp(web_app.context_path, web_app.web_app_dir) Trinidad::Extensions.configure_webapp_extensions(web_app.extensions, @tomcat, app_context) - lifecycle = web_app.war? ? Lifecycle::War.new(web_app) : Lifecycle::Default.new(web_app) - app_context.add_lifecycle_listener(lifecycle) + app_context.add_lifecycle_listener(web_app.define_lifecycle) - {:context => app_context, :monitor => web_app.monitor} + {:context => app_context, :app => web_app, :monitor => web_app.monitor} end def add_service_connector(options, protocol = nil) connector = Trinidad::Tomcat::Connector.new(protocol) opts = options.dup @@ -192,10 +188,12 @@ Trinidad::Tomcat::KeyTool.main(keytool_args.to_java(:string)) end def start + trap_signals(@tomcat) + @tomcat.start @tomcat.server.await end private @@ -209,8 +207,13 @@ } default_app[:rackup] = config[:rackup] if (config.has_key?(:rackup)) config[:web_apps] = { :default => default_app } end + end + + def trap_signals(tomcat) + trap('INT') { tomcat.stop } + trap('TERM') { tomcat.stop } end end end