lib/trinidad/server.rb in trinidad-1.2.1 vs lib/trinidad/server.rb in trinidad-1.2.2

- old
+ new

@@ -12,11 +12,12 @@ :default_web_xml => 'config/web.xml', :port => 3000, :jruby_min_runtimes => 1, :jruby_max_runtimes => 5, :address => 'localhost', - :log => 'INFO' + :log => 'INFO', + :trap => true } end def initialize(config = {}) load_config(config) @@ -188,16 +189,21 @@ Trinidad::Tomcat::KeyTool.main(keytool_args.to_java(:string)) end def start - trap_signals(@tomcat) + trap_signals if @config[:trap] @tomcat.start @tomcat.server.await end + def stop + @tomcat.stop + @tomcat.destroy + end + private def add_default_web_app!(config) if (!config.has_key?(:web_apps) && !config.has_key?(:apps_base)) default_app = { @@ -209,11 +215,11 @@ config[:web_apps] = { :default => default_app } end end - def trap_signals(tomcat) - trap('INT') { tomcat.stop } - trap('TERM') { tomcat.stop } + def trap_signals + trap('INT') { stop } + trap('TERM') { stop } end end end