trinidad 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == Trinidad 1.3.0 (2011-12-30)
2
+
3
+ * Support for virtual hosts
4
+ * Ruby configuration DSL
5
+ * Rack handler
6
+
7
+ == Trinidad_jars 1.0.2 (2011-09-10)
8
+
9
+ * Bump Tomcat's version to 7.0.21
10
+
1
11
  == Trinidad 1.2.3 (2011-07-13)
2
12
 
3
13
  * fix JRuby class loader generation with hot deploy
data/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # Trinidad
2
+
3
+ Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
4
+
5
+ * Mail list: http://groups.google.com/group/rails-trinidad
6
+ * Bug tracker: http://github.com/trinidad/trinidad/issues
7
+ * Irc channel on Freenode: #trinidad
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ $ jruby -S gem install trinidad
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```
18
+ $ cd myapp
19
+ $ jruby -S trinidad
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ Trinidad allows you to configure some parameters when the server is started from the command line, the following is a list of the currently supported options:
25
+
26
+ ```
27
+ * -p, --port PORT => port to bind to.
28
+ * -e, --env ENVIRONMENT => rails environment.
29
+ * -c, --context CONTEXT => application context path.
30
+ * --lib, --jars LIBS_DIR => directory containing jars.
31
+ * --classes CLASSES_DIR => directory containing classes.
32
+ * -r, --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
33
+ * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
34
+ * -t, --threadsafe => shortcut to work in threadsafe mode. Setting jruby_min_runtimes and jruby_max_runtimes to 1 in the configuration file the server behaves as the same way.
35
+ * -l, --load EXTENSION_NAMES => load extensions to use their command line options.
36
+ * --address HOST => set the server host.
37
+ * -g, --log LEVEL => set the log level, default INFO.
38
+ * --apps APPS_BASE_DIRECTORY => set the applications base directory.
39
+ ```
40
+ You can also specify a default web.xml to configure your web application. By default the server tries to load the file `config/web.xml` but you can modify this path by adding the option `default_web_xml` within your configuration file.
41
+
42
+ Other advanced options can be found on the wiki: http://wiki.github.com/trinidad/trinidad/advanced-configuration
43
+
44
+ ### Yaml comfiguration
45
+
46
+ The server can also be configured from a yaml file. By default, if a file is not specified, the server tries to load the file `config/trinidad.yml`. Within this file you can add other options like jruby.min.runtimes(:jruby _ min _ runtimes) or jruby.max.runtimes(:jruby _ max _ runtimes).
47
+
48
+ ```
49
+ $ jruby -S trinidad --config my_custom_configuration.yml
50
+ ```
51
+
52
+ ```yml
53
+ ---
54
+ port: 4000
55
+ address: 0.0.0.0
56
+ ```
57
+
58
+ ### Ruby configuration
59
+
60
+ You can use pure ruby to configure Trinidad. Actually, the yaml configuration file is mapped directly into this configuration. It follows the same convention as the yaml configuration so the file `config/trinidad.rb` is loaded by default if if exists.
61
+
62
+ ```ruby
63
+ Trinidad.configure do |config|
64
+ config.port = 4000
65
+ config.address = '0.0.0.0'
66
+ end
67
+ ```
68
+
69
+ ## Hot deployment
70
+
71
+ Although the early versions of Trinidad used an extension to let deploy applications monitorizing a file, since Trinidad 1.1.0 this feature is integrated into the core. When the file `tmp/restart.txt` is modified, the server reloads the application that the file belongs. This file can be modified with the option `monitor`.
72
+
73
+ ## Virtual hosts
74
+
75
+ It's posible to configure Trinidad with multiple hosts and load the applications under them automatically. Take into account that each host must have its applications in a different directory.
76
+
77
+ ```ruby
78
+ Trinidad.configure do |config|
79
+ config.hosts = {
80
+ # applications_path => host_name_list (the first one in the list is real host name, the other ones are aliases)
81
+ 'app_local' => ['localhost', '127.0.0.1'],
82
+ 'apps_lol' => ['lolhost', 'lol'],
83
+ 'apps_foo' => 'foo'
84
+ }
85
+ end
86
+ ```
87
+
88
+ If the applications are configured via the web_apps section, the host for each app can be added with the key `hosts` under each application. If several applications belong to the same host put them under the same directory and specify the name of the host for each one:
89
+
90
+ ```ruby
91
+ Trinidad.configure do |config|
92
+ config.web_apps = {
93
+ :mock1 => {
94
+ :web_app_dir => 'rails_apps/mock1',
95
+ # host_name_list (the first one in the list is real host name, the other ones are aliases)
96
+ :hosts => ['rails.virtual.host', 'rails.host']
97
+ },
98
+ :mock2 => {
99
+ :web_app_dir => 'rails_apps/mock2',
100
+ :hosts => 'rails.virtual.host'
101
+ },
102
+ :mock3 => {
103
+ :web_app_dir => 'rack_apps/mock3',
104
+ # host_name_list (the first one in the list is real host name, the other ones are aliases)
105
+ :hosts => ['rack.virtual.host', 'rack.host']
106
+ }
107
+ }
108
+ end
109
+ ```
110
+
111
+ ## Extensions
112
+
113
+ From the version 0.8.0 Trinidad allows to extend the server with more Tomcat features, here there is a list with the current available extensions:
114
+
115
+
116
+ * Database connection pooling: https://github.com/trinidad/trinidad_dbpool_extension
117
+ * Daemon based on Akuma (ala GF gem): http://github.com/trinidad/trinidad_daemon_extension
118
+ * Init services based on Apache Commons Daemon (supports Unix and Windows systems): http://github.com/trinidad/trinidad_init_services
119
+ * Sandbox, management console and REST api: http://github.com/trinidad/trinidad_sandbox_extension
120
+ * Logging, enhance the Trinidad's logging system: http://github.com/trinidad/trinidad_logging_extension
121
+ * Lifecycle, application and server lifecycle management: http://github.com/trinidad/trinidad_lifecycle_extension
122
+ * Scheduler, based on Quartz: http://github.com/trinidad/trinidad_scheduler_extension
123
+
124
+
125
+ You can find further information on how to write your own extension in the wiki: http://wiki.github.com/trinidad/trinidad/extensions
126
+
127
+ ## Copyright
128
+
129
+ Copyright (c) 2011 David Calavera<calavera@apache.org>. See LICENSE for details.
data/bin/trinidad CHANGED
@@ -3,4 +3,4 @@
3
3
  require "trinidad"
4
4
 
5
5
  opts = Trinidad::CommandLineParser.parse(ARGV)
6
- Trinidad::Server.new(opts).start
6
+ Trinidad::Server.new(Trinidad.configuration).start
@@ -0,0 +1,33 @@
1
+ require 'rack'
2
+ require 'trinidad'
3
+
4
+ gem 'jruby-rack'
5
+ require 'rack/handler/servlet'
6
+
7
+ module Rack
8
+ module Handler
9
+ class Trinidad < Rack::Handler::Servlet
10
+ def self.run(app, options={})
11
+ opts = options.dup
12
+
13
+ # some libs use :Port, :port and :Host, :host, unify this
14
+ opts.each {|k,v| opts[k.to_s.downcase.to_sym] = v}
15
+
16
+ opts[:app] = app
17
+ opts[:port] ||= 3000
18
+ opts[:address] = opts[:host] || 'localhost'
19
+ opts[:servlet] = {:instance => servlet, :name => 'RackServlet'}
20
+ opts[:jruby_max_runtimes] ||= 1
21
+
22
+ context = org.jruby.rack.embed.Context.new('Trinidad')
23
+ dispatcher = org.jruby.rack.embed.Dispatcher.new(context, self.new(app))
24
+ servlet = org.jruby.rack.embed.Servlet.new(dispatcher, context)
25
+
26
+ ::Trinidad::CommandLineParser.new.load_configuration(opts)
27
+ ::Trinidad::Server.new.start
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Rack::Handler.register 'trinidad', 'Rack::Handler::Trinidad'
@@ -9,16 +9,7 @@ module Trinidad
9
9
  end
10
10
 
11
11
  def initialize
12
- @default_options = {
13
- :port => 3000,
14
- :environment => 'development',
15
- :context_path => '',
16
- :libs_dir => 'lib',
17
- :classes_dir => 'classes',
18
- :ssl_port => 8443,
19
- :ajp_port => 8009,
20
- :config => 'config/trinidad.yml'
21
- }
12
+ @default_options = {}
22
13
  end
23
14
 
24
15
  def parse!(argv)
@@ -29,18 +20,35 @@ module Trinidad
29
20
  exit(1)
30
21
  end
31
22
 
32
- if default_options.has_key?(:config)
33
- require 'yaml'
34
- require 'erb'
35
- default_options[:config] = File.expand_path(default_options[:config], default_options[:web_app_dir] || Dir.pwd)
23
+ load_configuration(default_options)
24
+ end
36
25
 
37
- if File.exist?(default_options[:config])
38
- config_options = YAML.load(ERB.new(File.read(default_options[:config])).result(binding))
39
- default_options.deep_merge!(config_options.symbolize!)
26
+ def load_configuration(options)
27
+ base_dir = options[:web_app_dir] || Dir.pwd
28
+ config = options.delete(:config) || Dir.glob(File.join(base_dir, 'config', 'trinidad.{yml,rb}')).first
29
+ if config and config = File.expand_path(config, base_dir)
30
+ if yaml_configuration?(config)
31
+ require 'yaml'
32
+ require 'erb'
33
+ config_options = YAML.load(ERB.new(File.read(config)).result(binding))
34
+ options.deep_merge!(config_options.symbolize!)
40
35
  end
41
36
  end
42
37
 
43
- default_options
38
+ Trinidad.configure(options)
39
+ if ruby_configuration?(config)
40
+ load config
41
+ end
42
+
43
+ options
44
+ end
45
+
46
+ def yaml_configuration?(config)
47
+ config && File.exist?(config) && config =~ /\.yml$/
48
+ end
49
+
50
+ def ruby_configuration?(config)
51
+ config && File.exist?(config) && config =~ /\.rb$/
44
52
  end
45
53
 
46
54
  def options_parser
@@ -79,20 +87,20 @@ module Trinidad
79
87
  end
80
88
 
81
89
  opts.on('-s', '--ssl [SSL_PORT]', 'Enable secure socket layout',
82
- "default port: #{default_options[:ssl_port]}") do |v|
83
- ssl_port = v.nil? ? default_options.delete(:ssl_port) : v.to_i
90
+ "default port: 8443") do |v|
91
+ ssl_port = v.nil? ? 8443 : v.to_i
84
92
  default_options[:ssl] = {:port => ssl_port}
85
93
  end
86
94
 
87
95
  opts.on('-a', '--ajp [AJP_PORT]', 'Enable ajp connections',
88
- "default port: #{default_options[:ajp_port]}") do |v|
89
- ajp_port = v.nil? ? default_options.delete(:ajp_port) : v.to_i
96
+ "default port: 8009") do |v|
97
+ ajp_port = v.nil? ? 8009 : v.to_i
90
98
  default_options[:ajp] = {:port => ajp_port}
91
99
  end
92
100
 
93
101
  opts.on('-f', '--config [CONFIG_FILE]', 'Configuration file',
94
- "default: #{default_options[:config]}") do |file|
95
- default_options[:config] = file unless file.nil?
102
+ "default: config/trinidad.yml") do |file|
103
+ default_options[:config] = file || 'config/trinidad.yml'
96
104
  end
97
105
 
98
106
  opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file',
@@ -0,0 +1,52 @@
1
+ module Trinidad
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure(options = {})
7
+ self.configuration ||= Configuration.new(options)
8
+ yield self.configuration if block_given?
9
+ self.configuration
10
+ end
11
+
12
+ # test only purposes
13
+ def self.cleanup
14
+ self.configuration = nil
15
+ end
16
+
17
+ class Configuration
18
+ attr_accessor :port, :address, :environment, :context_path, :libs_dir, :classes_dir,
19
+ :default_web_xml, :log, :jruby_min_runtimes, :jruby_max_runtimes,
20
+ :monitor, :http, :ajp, :ssl, :extensions, :apps_base, :web_apps, :web_app_dir,
21
+ :trap, :rackup, :servlet, :public, :hosts
22
+
23
+ def initialize(options = {})
24
+ @environment = 'development'
25
+ @context_path = '/'
26
+ @libs_dir = 'lib'
27
+ @classes_dir = 'classes'
28
+ @default_web_xml = 'config/web.xml'
29
+ @port = 3000
30
+ @jruby_min_runtimes = 1
31
+ @jruby_max_runtimes = 5
32
+ @address = 'localhost'
33
+ @log = 'INFO'
34
+ @trap = true
35
+
36
+ options.symbolize!.each {|k, v| self[k] = v}
37
+ end
38
+
39
+ def [](name)
40
+ respond_to?(name) ? send(name) : nil
41
+ end
42
+
43
+ def []=(name, value)
44
+ send :"#{name}=", value
45
+ end
46
+
47
+ def has_key?(name)
48
+ instance_variable_defined?(name) rescue false
49
+ end
50
+ alias_method :key?, :has_key?
51
+ end
52
+ end
@@ -18,12 +18,12 @@ module Trinidad
18
18
  context_config = listeners && listeners.find do |listener|
19
19
  listener.is_a?(Trinidad::Tomcat::ContextConfig)
20
20
  end
21
-
21
+
22
22
  unless context_config
23
23
  context_config = Trinidad::Tomcat::ContextConfig.new
24
24
  context.addLifecycleListener(context_config)
25
25
  end
26
-
26
+
27
27
  context_config.setDefaultWebXml(descriptor)
28
28
  end
29
29
  descriptor
@@ -31,7 +31,11 @@ module Trinidad
31
31
 
32
32
  def configure_rack_servlet(context)
33
33
  wrapper = context.create_wrapper
34
- wrapper.servlet_class = @webapp.servlet[:class]
34
+ if @webapp.servlet[:instance]
35
+ wrapper.servlet = @webapp.servlet[:instance]
36
+ else
37
+ wrapper.servlet_class = @webapp.servlet[:class]
38
+ end
35
39
  wrapper.name = @webapp.servlet[:name]
36
40
 
37
41
  context.add_child(wrapper)
@@ -39,7 +43,7 @@ module Trinidad
39
43
  end
40
44
 
41
45
  def configure_rack_listener(context)
42
- context.addApplicationListener(@webapp.rack_listener)
46
+ context.addApplicationListener(@webapp.rack_listener) unless @webapp.servlet[:instance]
43
47
  end
44
48
 
45
49
  def configure_init_params(context)
@@ -63,7 +63,7 @@ module Trinidad
63
63
  context.add_lifecycle_listener Trinidad::Tomcat::Tomcat::DefaultWebXmlListener.new
64
64
 
65
65
  config = Trinidad::Tomcat::ContextConfig.new
66
- config.default_web_xml = 'org/apache/catalin/startup/NO_DEFAULT_XML'
66
+ config.default_web_xml = 'org/apache/catalina/startup/NO_DEFAULT_XML'
67
67
  context.add_lifecycle_listener config
68
68
 
69
69
  Trinidad::Extensions.configure_webapp_extensions(web_app.extensions, @tomcat, context)
@@ -1,7 +1,10 @@
1
1
  module Trinidad
2
2
  class LogFormatter < Java::JavaUtilLogging::Formatter
3
- def initialize format = "yyyy-MM-dd HH:mm:ss"
3
+ def initialize(format = "yyyy-MM-dd HH:mm:ss")
4
4
  @format = Java::JavaText::SimpleDateFormat.new format
5
+ calendar = Java::JavaUtil::GregorianCalendar.new
6
+ calendar.time_zone = Java::JavaUtil::SimpleTimeZone.new(0, 'UTC')
7
+ @format.calendar = calendar
5
8
  end
6
9
 
7
10
  def format(record)
@@ -12,4 +15,4 @@ module Trinidad
12
15
  "#{timestamp} #{level}: #{message}\n"
13
16
  end
14
17
  end
15
- end
18
+ end
@@ -3,23 +3,7 @@ module Trinidad
3
3
  class Server
4
4
  attr_reader :tomcat, :config
5
5
 
6
- def default_options
7
- {
8
- :environment => 'development',
9
- :context_path => '/',
10
- :libs_dir => 'lib',
11
- :classes_dir => 'classes',
12
- :default_web_xml => 'config/web.xml',
13
- :port => 3000,
14
- :jruby_min_runtimes => 1,
15
- :jruby_max_runtimes => 5,
16
- :address => 'localhost',
17
- :log => 'INFO',
18
- :trap => true
19
- }
20
- end
21
-
22
- def initialize(config = {})
6
+ def initialize(config = Trinidad.configuration)
23
7
  load_config(config)
24
8
  load_tomcat_server
25
9
  apps = create_web_apps
@@ -27,17 +11,17 @@ module Trinidad
27
11
  end
28
12
 
29
13
  def load_config(config)
30
- @config = default_options.deep_merge(config).symbolize!
31
- add_default_web_app!(@config)
14
+ @config = config
15
+ add_default_web_app!(config)
32
16
  end
33
17
 
34
18
  def load_tomcat_server
35
19
  @tomcat = Trinidad::Tomcat::Tomcat.new
36
20
  @tomcat.base_dir = Dir.pwd
37
- @tomcat.hostname = @config[:address]
21
+ @tomcat.hostname = @config[:address] || 'localhost'
38
22
  @tomcat.server.address = @config[:address]
39
23
  @tomcat.port = @config[:port].to_i
40
- @tomcat.host.app_base = @config[:apps_base] || Dir.pwd
24
+ create_hosts
41
25
  @tomcat.enable_naming
42
26
 
43
27
  add_http_connector if http_configured?
@@ -47,6 +31,31 @@ module Trinidad
47
31
  @tomcat = Trinidad::Extensions.configure_server_extensions(@config[:extensions], @tomcat)
48
32
  end
49
33
 
34
+ def create_hosts
35
+ if @config[:hosts]
36
+ @config[:hosts].each do |apps_base, names|
37
+ create_host(apps_base, names)
38
+ end
39
+
40
+ set_default_host
41
+ elsif @config[:web_apps]
42
+ # create the hosts when they are specified for each app into
43
+ # web_apps. We must create them before creating the
44
+ # applications.
45
+ @config[:web_apps].each do |name, app_config|
46
+ if host_names = app_config.delete(:hosts)
47
+ dir = app_config[:web_app_dir] || Dir.pwd
48
+ apps_base = File.dirname(dir) == '.' ? dir : File.dirname(dir)
49
+ app_config[:host] = create_host(apps_base, host_names)
50
+ end
51
+
52
+ set_default_host
53
+ end
54
+ else
55
+ @tomcat.host.app_base = @config[:apps_base] || Dir.pwd
56
+ end
57
+ end
58
+
50
59
  def create_web_apps
51
60
  apps = []
52
61
  apps << create_from_web_apps
@@ -56,14 +65,16 @@ module Trinidad
56
65
  end
57
66
 
58
67
  def load_host_monitor(apps)
59
- @tomcat.host.add_lifecycle_listener(Trinidad::Lifecycle::Host.new(@tomcat, *apps))
68
+ @tomcat.engine.find_children.each do |host|
69
+ host.add_lifecycle_listener(Trinidad::Lifecycle::Host.new(@tomcat, *apps))
70
+ end
60
71
  end
61
72
 
62
73
  def create_from_web_apps
63
74
  if @config[:web_apps]
64
75
  @config[:web_apps].map do |name, app_config|
65
76
  app_config[:context_path] ||= (name.to_s == 'default' ? '' : "/#{name.to_s}")
66
- app_config[:web_app_dir] ||= Dir.pwd
77
+ app_config[:web_app_dir] ||= Dir.pwd
67
78
 
68
79
  create_web_app(app_config)
69
80
  end
@@ -71,30 +82,35 @@ module Trinidad
71
82
  end
72
83
 
73
84
  def create_from_apps_base
74
- if @config[:apps_base]
75
- apps_path = Dir.glob(File.join(@config[:apps_base], '*')).
76
- select {|path| !(path =~ /tomcat\.\d+$/) }
77
-
78
- apps_path.reject! {|path| apps_path.include?(path + '.war') }
79
-
80
- apps_path.map do |path|
81
- if (File.directory?(path) || path =~ /\.war$/)
82
- name = File.basename(path)
83
- app_config = {
84
- :context_path => (name == 'default' ? '' : "/#{name.to_s}"),
85
- :web_app_dir => File.expand_path(path)
86
- }
87
-
88
- create_web_app(app_config)
85
+ if @config[:apps_base] || @config[:hosts]
86
+ @tomcat.engine.find_children.map do |host|
87
+ apps_base = host.app_base
88
+
89
+ apps_path = Dir.glob(File.join(apps_base, '*')).
90
+ select {|path| !(path =~ /tomcat\.\d+$/) }
91
+
92
+ apps_path.reject! {|path| apps_path.include?(path + '.war') }
93
+
94
+ apps_path.map do |path|
95
+ if (File.directory?(path) || path =~ /\.war$/)
96
+ name = File.basename(path)
97
+ app_config = {
98
+ :context_path => (name == 'default' ? '' : "/#{name.to_s}"),
99
+ :web_app_dir => File.expand_path(path),
100
+ :host => host
101
+ }
102
+
103
+ create_web_app(app_config)
104
+ end
89
105
  end
90
- end
106
+ end.flatten
91
107
  end
92
108
  end
93
109
 
94
110
  def create_web_app(app_config)
95
111
  web_app = WebApp.create(@config, app_config)
96
112
 
97
- app_context = @tomcat.addWebapp(web_app.context_path, web_app.web_app_dir)
113
+ app_context = @tomcat.addWebapp(app_config[:host] || @tomcat.host, web_app.context_path, web_app.web_app_dir)
98
114
 
99
115
  Trinidad::Extensions.configure_webapp_extensions(web_app.extensions, @tomcat, app_context)
100
116
 
@@ -158,15 +174,15 @@ module Trinidad
158
174
  end
159
175
 
160
176
  def ssl_enabled?
161
- @config.has_key?(:ssl)
177
+ @config[:ssl] && !@config[:ssl].empty?
162
178
  end
163
179
 
164
180
  def ajp_enabled?
165
- @config.has_key?(:ajp)
181
+ @config[:ajp] && !@config[:ajp].empty?
166
182
  end
167
183
 
168
184
  def http_configured?
169
- @config.has_key?(:http) || @config[:address] != 'localhost'
185
+ (@config[:http] && !@config[:http].empty?) || @config[:address] != 'localhost'
170
186
  end
171
187
 
172
188
  def create_default_keystore(config)
@@ -204,14 +220,34 @@ module Trinidad
204
220
 
205
221
  private
206
222
 
223
+ def create_host(apps_base, names)
224
+ host_names = Array(names)
225
+ host_name = host_names.shift
226
+ unless host = @tomcat.engine.find_child(host_name)
227
+ host = Trinidad::Tomcat::StandardHost.new
228
+ host.name = host_name
229
+ host.app_base = apps_base || Dir.pwd
230
+ host_names.each {|h| host.add_alias(h) } unless host_names.empty?
231
+
232
+ @tomcat.engine.add_child host
233
+ end
234
+ host
235
+ end
236
+
237
+ def set_default_host
238
+ # FIXME: Remove when the issue below is solved.
239
+ # workaround to solve this Tomcat issue: https://issues.apache.org/bugzilla/show_bug.cgi?id=52387
240
+ @tomcat.host = @tomcat.engine.find_children.first
241
+ end
242
+
207
243
  def add_default_web_app!(config)
208
- if (!config.has_key?(:web_apps) && !config.has_key?(:apps_base))
244
+ if (!config[:web_apps] && !config[:apps_base] && !config[:hosts])
209
245
  default_app = {
210
246
  :context_path => config[:context_path],
211
247
  :web_app_dir => config[:web_app_dir] || Dir.pwd,
212
248
  :log => config[:log]
213
249
  }
214
- default_app[:rackup] = config[:rackup] if (config.has_key?(:rackup))
250
+ default_app[:rackup] = config[:rackup] if config[:rackup]
215
251
 
216
252
  config[:web_apps] = { :default => default_app }
217
253
  end
@@ -132,12 +132,12 @@ module Trinidad
132
132
  end
133
133
 
134
134
  def configure_rack_servlet(servlet_class, servlet_name)
135
- servlet_config = @config[:servlet] || @app_config[:servlet]
136
- if servlet_config
137
- servlet_class = servlet_config[:class]
138
- servlet_name = servlet_config[:name]
139
- end
140
- @servlet = {:class => servlet_class, :name => servlet_name}
135
+ servlet_config = @config[:servlet] || @app_config[:servlet] || {}
136
+ @servlet = {
137
+ :class => servlet_config[:class] || servlet_class,
138
+ :name => servlet_config[:name] || servlet_name,
139
+ :instance => servlet_config[:instance]
140
+ }
141
141
  end
142
142
 
143
143
  def self.autodetect_configuration(config, app_config)
data/lib/trinidad.rb CHANGED
@@ -6,8 +6,8 @@ require 'jruby-rack'
6
6
  gem 'trinidad_jars'
7
7
 
8
8
  require 'trinidad/core_ext'
9
-
10
9
  require 'trinidad/extensions'
10
+ require 'trinidad/configuration'
11
11
  require 'trinidad/command_line_parser'
12
12
  require 'trinidad/jars'
13
13
  require 'trinidad/server'
@@ -21,7 +21,8 @@ require 'trinidad/web_app'
21
21
  require 'trinidad/rails_web_app'
22
22
  require 'trinidad/rackup_web_app'
23
23
  require 'trinidad/war_web_app'
24
+ require 'rack/handler/trinidad'
24
25
 
25
26
  module Trinidad
26
- VERSION = '1.2.3'
27
+ VERSION = '1.3.0'
27
28
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: trinidad
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.3
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Calavera
@@ -10,64 +10,74 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-13 00:00:00 +02:00
14
- default_executable: trinidad
13
+ date: 2011-12-30 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: trinidad_jars
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ version_requirements: &id001 !ruby/object:Gem::Requirement
20
18
  none: false
21
19
  requirements:
22
20
  - - ">="
23
21
  - !ruby/object:Gem::Version
24
22
  version: 1.0.1
23
+ requirement: *id001
24
+ prerelease: false
25
25
  type: :runtime
26
- version_requirements: *id001
27
26
  - !ruby/object:Gem::Dependency
28
- name: jruby-rack
27
+ name: rack
28
+ version_requirements: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ requirement: *id002
29
35
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ type: :runtime
37
+ - !ruby/object:Gem::Dependency
38
+ name: jruby-rack
39
+ version_requirements: &id003 !ruby/object:Gem::Requirement
31
40
  none: false
32
41
  requirements:
33
42
  - - ">="
34
43
  - !ruby/object:Gem::Version
35
- version: 1.0.9
44
+ version: 1.1.2
45
+ requirement: *id003
46
+ prerelease: false
36
47
  type: :runtime
37
- version_requirements: *id002
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: rspec
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ version_requirements: &id004 !ruby/object:Gem::Requirement
42
51
  none: false
43
52
  requirements:
44
- - - ">="
53
+ - - ~>
45
54
  - !ruby/object:Gem::Version
46
- version: "0"
55
+ version: 2.5.0
56
+ requirement: *id004
57
+ prerelease: false
47
58
  type: :development
48
- version_requirements: *id003
49
59
  - !ruby/object:Gem::Dependency
50
60
  name: mocha
51
- prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
61
+ version_requirements: &id005 !ruby/object:Gem::Requirement
53
62
  none: false
54
63
  requirements:
55
64
  - - ">="
56
65
  - !ruby/object:Gem::Version
57
66
  version: "0"
67
+ requirement: *id005
68
+ prerelease: false
58
69
  type: :development
59
- version_requirements: *id004
60
70
  - !ruby/object:Gem::Dependency
61
71
  name: fakefs
62
- prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: &id006 !ruby/object:Gem::Requirement
64
73
  none: false
65
74
  requirements:
66
75
  - - ">="
67
76
  - !ruby/object:Gem::Version
68
- version: "0"
77
+ version: 0.4.0
78
+ requirement: *id006
79
+ prerelease: false
69
80
  type: :development
70
- version_requirements: *id005
71
81
  description: Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container
72
82
  email: calavera@apache.org
73
83
  executables:
@@ -75,15 +85,17 @@ executables:
75
85
  extensions: []
76
86
 
77
87
  extra_rdoc_files:
78
- - README.rdoc
88
+ - README.md
79
89
  - LICENSE
80
90
  files:
81
91
  - bin/trinidad
82
92
  - lib/trinidad.rb
83
93
  - History.txt
84
94
  - LICENSE
85
- - README.rdoc
95
+ - README.md
96
+ - lib/rack/handler/trinidad.rb
86
97
  - lib/trinidad/command_line_parser.rb
98
+ - lib/trinidad/configuration.rb
87
99
  - lib/trinidad/core_ext.rb
88
100
  - lib/trinidad/extensions.rb
89
101
  - lib/trinidad/log_formatter.rb
@@ -97,7 +109,6 @@ files:
97
109
  - lib/trinidad/lifecycle/lifecycle_listener_host.rb
98
110
  - lib/trinidad/lifecycle/lifecycle_listener_war.rb
99
111
  - lib/trinidad/lifecycle/takeover.rb
100
- has_rdoc: true
101
112
  homepage: http://github.com/calavera/trinidad
102
113
  licenses: []
103
114
 
@@ -111,6 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
122
  requirements:
112
123
  - - ">="
113
124
  - !ruby/object:Gem::Version
125
+ hash: 2
126
+ segments:
127
+ - 0
114
128
  version: "0"
115
129
  required_rubygems_version: !ruby/object:Gem::Requirement
116
130
  none: false
@@ -121,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
135
  requirements: []
122
136
 
123
137
  rubyforge_project: trinidad
124
- rubygems_version: 1.5.1
138
+ rubygems_version: 1.8.9
125
139
  signing_key:
126
140
  specification_version: 2
127
141
  summary: Simple library to run rails applications into an embedded Tomcat
data/README.rdoc DELETED
@@ -1,66 +0,0 @@
1
- = trinidad
2
-
3
- Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
4
-
5
- * Mail list: http://groups.google.com/group/rails-trinidad
6
- * Bug tracker: http://github.com/trinidad/trinidad/issues
7
- * Irc channel on Freenode: #trinidad
8
-
9
- == INSTALL:
10
-
11
- $ jruby -S gem install trinidad
12
-
13
- == USAGE:
14
-
15
- $ cd myapp
16
- $ jruby -S trinidad
17
-
18
- == CONFIGURATION:
19
-
20
- Trinidad allows you to configure some parameters when the server is started from the command line, the following is a list of the currently supported options:
21
-
22
- * -p, --port PORT => port to bind to.
23
- * -e, --env ENVIRONMENT => rails environment.
24
- * -c, --context CONTEXT => application context path.
25
- * --lib, --jars LIBS_DIR => directory containing jars.
26
- * --classes CLASSES_DIR => directory containing classes.
27
- * -r, --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
28
- * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
29
- * -t, --threadsafe => shortcut to work in threadsafe mode. Setting jruby_min_runtimes and jruby_max_runtimes to 1 in the configuration file the server behaves as the same way.
30
- * -l, --load EXTENSION_NAMES => load extensions to use their command line options.
31
- * --address HOST => set the server host.
32
- * -g, --log LEVEL => set the log level, default INFO.
33
- * --apps APPS_BASE_DIRECTORY => set the applications base directory.
34
-
35
- The server can also be configured from a yaml file. By default, if a file is not specified, the server tries to load the file <em>config/trinidad.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
36
-
37
- jruby -S trinidad --config my_custom_configuration.yml
38
-
39
- You can also specify a default web.xml to configure your web application. By default the server tries to load the file <em>config/web.xml</em> but you can modify this path by adding the option <em>default_web_xml</em> within your configuration file.
40
-
41
- Other advanced options can be found on the wiki: http://wiki.github.com/trinidad/trinidad/advanced-configuration
42
-
43
- == HOT DEPLOYMENT:
44
-
45
- Although the early versions of Trinidad used an extension to let deploy applications monitorizing a file, since Trinidad 1.1.0 this feature is
46
- integrated into the core. When the file `tmp/restart.txt` is modified, the server reloads the application that the file belongs. This file can be
47
- modified with the option `:monitor`.
48
-
49
- == EXTENSIONS:
50
-
51
- From the version 0.8.0 Trinidad allows to extend the server with more Tomcat features, here there is a list with the current available extensions:
52
-
53
- * Database connection pooling: http://github.com/trinidad/trinidad-dbpool
54
- * Daemons:
55
- ** Daemon based on Akuma (ala GF gem): http://github.com/trinidad/trinidad_daemon_extension
56
- ** Daemon based on Apache Commons Daemon (supports Unix and Windows systems): http://github.com/trinidad/trinidad_daemon
57
- * Sandbox, management console and REST api: http://github.com/trinidad/trinidad_sandbox_extension
58
- * Logging, enhance the Trinidad's logging system: http://github.com/trinidad/trinidad_logging_extension
59
- * Lifecycle, application and server lifecycle management: http://github.com/trinidad/trinidad_lifecycle_extension
60
- * Scheduler, based on Quartz: http://github.com/trinidad/trinidad_scheduler_extension
61
-
62
- You can find further information on how to write your own extension in the wiki: http://wiki.github.com/trinidad/trinidad/extensions
63
-
64
- == Copyright
65
-
66
- Copyright (c) 2011 David Calavera<calavera@apache.org>. See LICENSE for details.