trinidad 1.3.5 → 1.4.0.RC

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
- source :gemcutter
1
+ source 'http://rubygems.org'
2
2
 
3
- gemspec :name => "trinidad"
3
+ gemspec :name => "trinidad"
4
+
5
+ # for the integration tests :
6
+ group :test do
7
+ gem "rails", "~> 3.2"
8
+ gem "jruby-openssl"
9
+ end
@@ -1,3 +1,46 @@
1
+ == Trinidad 1.4.0.RC (2012-07-03)
2
+
3
+ * requires latest Tomcat 7.0.28 (jars 1.0.5) due context reloading fix
4
+ * requires latest jruby-rack 1.1.7 due delegating RackLogger to JUL
5
+ * Trinidad::WebApp API revisited some changes are non-backwards compatible !
6
+ * enable running multiple applications with different ruby versions (using the
7
+ jruby_compat_version configuration option)
8
+ * allow arbitrary keys to be stored with Trinidad::Configuration
9
+ * changed Trinidad::Lifecycle::Base to be a (ruby-like) base lifecycle listener
10
+ skeleton implementation, thus removed all web app specifics from the class
11
+ (include Trinidad::Lifecycle::WebApp::Shared to gain the same functionality)
12
+ * removed unused Trinidad::Rack module and KeyTool from Trinidad::Tomcat
13
+ * reinvented server/application logging with Trinidad::Logging :
14
+ - refactored Trinidad's global logging configuration with JUL
15
+ - application logs into log/env.log by default with daily rolling
16
+ - console logs are now less chatty and only print logs from applications
17
+ running in development mode (configuration to come in a later release)
18
+ - make sure Trinidad's custom log formatter prints thrown exceptions
19
+ - use local timestamps with (file) log formatter by default
20
+ * Trinidad::Server#add_web_app for code re-use during rolling redeploys
21
+ * refactored application (monitor based `touch 'tmp/restart.txt'`) reloading
22
+ - bring back synchronous context reloading and make it default
23
+ - "zero downtime" async rolling reload is still supported and configurable via
24
+ the reload_strategy: rolling configuration option
25
+ - updated the context restart code - hot deploys should now work reliably (#75)
26
+ - moved Trinidad::Lifecycle::Host under Trinidad::Lifecycle::WebApp::Host
27
+ - Trinidad::Lifecycle::Host now accepts a server instance instead of a tomcat
28
+ - introduced Trinidad::WebApp::Holder to be used instead of bare Hash
29
+ * add async_supported attribute for servlet (3.0) configuration
30
+
31
+ == Trinidad_jars 1.0.5 (2012-07-03)
32
+
33
+ * Upgrade to Tomcat 7.0.28
34
+ * Patched org.apache.juli.FileHandler to allow daily rolling customization
35
+
36
+ == Trinidad_jars 1.0.4 (2012-06-14)
37
+
38
+ * Upgrade to Tomcat 7.0.27
39
+
40
+ == Trinidad_jars 1.0.3 (2012-04-04)
41
+
42
+ * Upgrade to Tomcat 7.0.26
43
+
1
44
  == Trinidad 1.3.5 (2012-04-04)
2
45
 
3
46
  * Correctly detect :rackup from main config for web apps (#66)
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  == Trinidad
2
2
 
3
- Copyright (c) 2009 David Calavera
3
+ Copyright (c) 2009-2012 David Calavera
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -23,4 +23,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
24
  == Additional Bundled Software
25
25
 
26
- Apache Tomcat is licensed according to the terms of Apache License, Version 2.0 (current). See http://www.apache.org/licenses/LICENSE-2.0 for details.
26
+ Apache Tomcat is licensed according to the terms of Apache License, Version 2.0 (current).
27
+ See http://www.apache.org/licenses/LICENSE-2.0 for details.
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Trinidad
2
2
 
3
- Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
3
+ Trinidad allows you to run Rails or Rack applications within an embedded
4
+ Apache Tomcat container.
4
5
 
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
6
+ * Mailing List: http://groups.google.com/group/rails-trinidad
7
+ * Bug Tracker: http://github.com/trinidad/trinidad/issues
8
+ * IRC Channel (on FreeNode): #trinidad
8
9
 
9
10
  ## Installation
10
11
 
@@ -19,39 +20,43 @@ $ cd myapp
19
20
  $ jruby -S trinidad
20
21
  ```
21
22
 
22
- ### Advanced Rackup setup
23
+ ### Setup
23
24
 
24
- **Sinatra**
25
-
26
- You can run your Sinatra application with Trinidad from the command line like this:
25
+ If you use Bundler, you might want to add Trinidad to your *Gemfile*:
27
26
 
28
27
  ```
29
- $ ruby app.rb -s Trinidad
28
+ gem 'trinidad', :require => nil
30
29
  ```
31
30
 
32
- Or tou can configure your application to always use it:
31
+ **Rails**
33
32
 
34
- ```ruby
35
- require 'sinatra'
36
- require 'trinidad'
33
+ If you have Trinidad in your Gemfile you can start it with `rails server`:
37
34
 
38
- configure do
39
- set :server, :trinidad
40
- end
35
+ ```
36
+ $ rails s trinidad
41
37
  ```
42
38
 
43
- If you use Bundler, make sure you add Trinidad to your Gemfile:
39
+ or simply, if you prefer not to use the Rack handler, use:
44
40
 
45
41
  ```
46
- gem 'trinidad'
42
+ $ trinidad
47
43
  ```
48
44
 
49
- **Rails**
50
-
51
- If you already have Trinidad in your Gemfile you can start the server with the rails command:
45
+ **Sinatra**
52
46
 
53
47
  ```
54
- $ rails s trinidad
48
+ $ ruby app.rb -s Trinidad
49
+ ```
50
+
51
+ or configure your application to always use Trinidad:
52
+
53
+ ```ruby
54
+ require 'sinatra'
55
+ require 'trinidad'
56
+
57
+ configure do
58
+ set :server, :trinidad
59
+ end
55
60
  ```
56
61
 
57
62
  **Rackup**
@@ -70,7 +75,8 @@ Or you can set Trinidad by default in your `config.ru` file:
70
75
 
71
76
  ## Configuration
72
77
 
73
- 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:
78
+ Trinidad allows you to configure parameters from the command line, the following
79
+ is a list of the currently supported options (try `trinidad -h`):
74
80
 
75
81
  ```
76
82
  * -p, --port PORT => port to bind to.
@@ -86,47 +92,109 @@ Trinidad allows you to configure some parameters when the server is started from
86
92
  * -g, --log LEVEL => set the log level, default INFO.
87
93
  * --apps APPS_BASE_DIRECTORY => set the applications base directory.
88
94
  ```
89
- 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.
90
95
 
91
- Other advanced options can be found on the wiki: http://wiki.github.com/trinidad/trinidad/advanced-configuration
96
+ You can also specify a default *web.xml* to configure your web application.
97
+ By default the server tries to load the file *config/web.xml* but you can change
98
+ the path by adding the option `default_web_xml` within your configuration file.
92
99
 
93
- ### Yaml comfiguration
100
+ ### YAML Configuration
101
+
102
+ The server can also be configured from a .yml file. By default, if a file is
103
+ not specified, the server tries to load *config/trinidad.yml*.
104
+ Within this file you can specify options available on the command line and tune
105
+ server settings or configure multiple applications to be hosted on the server.
106
+
107
+ Advanced configuration options are explained in the wiki:
108
+ http://wiki.github.com/trinidad/trinidad/advanced-configuration
94
109
 
95
- 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).
96
110
 
97
111
  ```
98
- $ jruby -S trinidad --config my_custom_configuration.yml
112
+ $ jruby -S trinidad --config my_trinidad.yml
99
113
  ```
100
114
 
101
115
  ```yml
102
116
  ---
103
- port: 4000
117
+ port: 4242
104
118
  address: 0.0.0.0
105
119
  ```
106
120
 
107
- ### Ruby configuration
121
+ ### Ruby Configuration
108
122
 
109
- 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.
123
+ As an alternative to the *config/trinidad.yml* file, a .rb configuration file
124
+ might be used to setup Trinidad. It follows the same convention as the yaml
125
+ configuration - the file `config/trinidad.rb` is loaded by default if exists.
110
126
 
111
127
  ```ruby
112
128
  Trinidad.configure do |config|
113
- config.port = 4000
129
+ config.port = 4242
114
130
  config.address = '0.0.0.0'
115
131
  end
116
132
  ```
117
133
 
118
- ## Hot deployment
134
+ ### Logging
135
+
136
+ As you might notice on your first `trinidad` the server uses standard output :
137
+
138
+ ```
139
+ kares@theborg:~/workspace/trinidad/MegaUpload$ trinidad -p 8000 -e staging
140
+ Initializing ProtocolHandler ["http-bio-8000"]
141
+ Starting Servlet Engine: Apache Tomcat/7.0.28
142
+ Starting ProtocolHandler ["http-bio-8000"]
143
+ Context with name [/] has started rolling
144
+ Context with name [/] has completed rolling
145
+ ```
146
+
147
+ It also prints warnings and error messages on error output, while application
148
+ specific log messages (e.g. logs from `Rails.logger`) go into the expected file
149
+ location at *log/{environment}.log*.
150
+
151
+ Application logging performs daily rolling out of the box and only prints
152
+ messages from an application to the console while it runs in development mode.
153
+
154
+ Please note that these logging details as well as the logging format will be
155
+ configurable with *trinidad.yml/.rb* within the next **1.4.x** release.
119
156
 
120
- 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`.
157
+ ## Hot Deployment
121
158
 
122
- ## Virtual hosts
159
+ Trinidad supports monitoring a file to reload applications, when the file
160
+ *tmp/restart.txt* is updated (e.g. `touch tmp/restart.txt`), the server reloads
161
+ the application the file belongs.
162
+ The file monitor can be customized with the `monitor` configuration option.
123
163
 
124
- 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.
164
+ Since version **1.4.0** Trinidad supports 2 reload strategies :
165
+
166
+ * **restart** (default) synchronous reloading (exposed by Tomcat). This strategy
167
+ pauses incoming requests while it reloads the application and than serves them
168
+ once ready (or timeouts if it takes too long). It has been chosen as the default
169
+ strategy since **1.4.0** due it's more predictable memory requirements.
170
+
171
+ * **rolling** "zero-downtime" (asynchronous) reloading strategy similar to
172
+ Passenger's rolling reloads. This has been the default since **1.1.0** up till
173
+ Trinidad version **1.3.0**. If you use this you should account that while
174
+ rolling memory requirements for the JVM might increase quite a lot since
175
+ requests are being served and there's 2 versions of your application loaded at
176
+ the same time.
177
+
178
+ Configure the reload strategy per web application or globally e.g. :
179
+
180
+ ```yml
181
+ ---
182
+ port: 8080
183
+ environment: production
184
+ reload_strategy: rolling
185
+ ```
186
+
187
+ ## Virtual Hosts
188
+
189
+ It's possible to use Trinidad with multiple hosts and load the applications under
190
+ them automatically. Please remember that each host must have its applications in
191
+ a different directory.
125
192
 
126
193
  ```ruby
127
194
  Trinidad.configure do |config|
128
195
  config.hosts = {
129
- # applications_path => host_name_list (the first one in the list is real host name, the other ones are aliases)
196
+ # applications_path => host_name_list
197
+ # (first one is the real host name, the other ones are aliases)
130
198
  'app_local' => ['localhost', '127.0.0.1'],
131
199
  'apps_lol' => ['lolhost', 'lol'],
132
200
  'apps_foo' => 'foo'
@@ -134,14 +202,16 @@ Trinidad.configure do |config|
134
202
  end
135
203
  ```
136
204
 
137
- 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:
205
+ If applications are configured via the `web_apps` section, the host for each app
206
+ can be added with the `hosts` key under each application.
207
+ If several applications belong to the same host put them under the same directory
208
+ and specify the name of the host for each one e.g. :
138
209
 
139
210
  ```ruby
140
211
  Trinidad.configure do |config|
141
212
  config.web_apps = {
142
213
  :mock1 => {
143
214
  :web_app_dir => 'rails_apps/mock1',
144
- # host_name_list (the first one in the list is real host name, the other ones are aliases)
145
215
  :hosts => ['rails.virtual.host', 'rails.host']
146
216
  },
147
217
  :mock2 => {
@@ -150,7 +220,6 @@ Trinidad.configure do |config|
150
220
  },
151
221
  :mock3 => {
152
222
  :web_app_dir => 'rack_apps/mock3',
153
- # host_name_list (the first one in the list is real host name, the other ones are aliases)
154
223
  :hosts => ['rack.virtual.host', 'rack.host']
155
224
  }
156
225
  }
@@ -159,20 +228,21 @@ end
159
228
 
160
229
  ## Extensions
161
230
 
162
- 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:
231
+ Trinidad allows to extend itself with more (not just Tomcat) features,
232
+ here is a list of the available extensions that are "officially supported":
163
233
 
164
-
165
- * Database connection pooling: https://github.com/trinidad/trinidad_dbpool_extension
166
- * Daemon based on Akuma (ala GF gem): http://github.com/trinidad/trinidad_daemon_extension
167
- * Init services based on Apache Commons Daemon (supports Unix and Windows systems): http://github.com/trinidad/trinidad_init_services
168
- * Sandbox, management console and REST api: http://github.com/trinidad/trinidad_sandbox_extension
169
- * Logging, enhance the Trinidad's logging system: http://github.com/trinidad/trinidad_logging_extension
170
- * Lifecycle, application and server lifecycle management: http://github.com/trinidad/trinidad_lifecycle_extension
234
+ * Database Connection Pooling: http://github.com/trinidad/trinidad_dbpool_extension
235
+ * Daemonize Trinidad, based on Akuma: http://github.com/trinidad/trinidad_daemon_extension
236
+ * Init Services (for Unix and Windows), based on Commons Daemon: http://github.com/trinidad/trinidad_init_services
237
+ * Logging, enhance Trinidad's logging system: http://github.com/trinidad/trinidad_logging_extension
238
+ * Application and Server Lifecycle Management: http://github.com/trinidad/trinidad_lifecycle_extension
239
+ * Trinidad's Management Console and REST API: http://github.com/trinidad/trinidad_sandbox_extension
171
240
  * Scheduler, based on Quartz: http://github.com/trinidad/trinidad_scheduler_extension
241
+ * Valves - components inserted into the request pipeline (e.g. Access Log): http://github.com/trinidad/trinidad_valve_extension
172
242
 
173
-
174
- You can find further information on how to write your own extension in the wiki: http://wiki.github.com/trinidad/trinidad/extensions
243
+ You can find further information on how to write extensions in the wiki:
244
+ http://wiki.github.com/trinidad/trinidad/extensions
175
245
 
176
246
  ## Copyright
177
247
 
178
- Copyright (c) 2011 David Calavera<calavera@apache.org>. See LICENSE for details.
248
+ Copyright (c) 2011-2012 David Calavera. See LICENSE for details.
data/Rakefile CHANGED
@@ -18,9 +18,8 @@ def release(name, gem_file, version)
18
18
  exit!
19
19
  end
20
20
  sh "git commit --allow-empty -a -m 'Release #{name} #{version}'"
21
- sh "git tag v#{name}-#{version}"
22
- sh "git push origin master"
23
- sh "git push --tags"
21
+ sh "git tag #{name}-#{version}"
22
+ sh "git push origin master --tags"
24
23
  sh "gem push pkg/#{gem_file}"
25
24
  end
26
25
 
@@ -3,19 +3,15 @@ require 'java'
3
3
  require 'jruby-rack'
4
4
 
5
5
  require 'trinidad/version'
6
- require 'trinidad/core_ext'
7
6
  require 'trinidad/extensions'
8
7
  require 'trinidad/configuration'
9
8
  require 'trinidad/command_line_parser'
10
9
  require 'trinidad/jars'
10
+ require 'trinidad/logging'
11
11
  require 'trinidad/server'
12
- require 'trinidad/log_formatter'
13
- require 'trinidad/lifecycle/takeover'
14
- require 'trinidad/lifecycle/lifecycle_listener_host'
15
- require 'trinidad/lifecycle/lifecycle_listener_base'
16
- require 'trinidad/lifecycle/lifecycle_listener_default'
17
- require 'trinidad/lifecycle/lifecycle_listener_war'
12
+ require 'trinidad/lifecycle/base'
13
+ require 'trinidad/lifecycle/host'
14
+ require 'trinidad/lifecycle/web_app/shared'
15
+ require 'trinidad/lifecycle/web_app/default'
16
+ require 'trinidad/lifecycle/web_app/war'
18
17
  require 'trinidad/web_app'
19
- require 'trinidad/rails_web_app'
20
- require 'trinidad/rackup_web_app'
21
- require 'trinidad/war_web_app'
@@ -1,8 +1,5 @@
1
1
  module Trinidad
2
- require 'optparse'
3
-
4
2
  class CommandLineParser
5
- attr_reader :default_options
6
3
 
7
4
  def self.parse(argv)
8
5
  CommandLineParser.new.parse!(argv)
@@ -12,10 +9,13 @@ module Trinidad
12
9
  CommandLineParser.new.load!(options)
13
10
  end
14
11
 
12
+ attr_reader :default_options
13
+
15
14
  def initialize
16
15
  @default_options = {}
17
16
  end
18
17
 
18
+ # Parse the arguments and return the loaded Trinidad configuration.
19
19
  def parse!(argv)
20
20
  begin
21
21
  options_parser.parse!(argv)
@@ -27,107 +27,106 @@ module Trinidad
27
27
  load!(default_options)
28
28
  end
29
29
 
30
+ # Load the configuration from the given options and return it.
30
31
  def load!(options)
31
- base_dir = options[:web_app_dir] || Dir.pwd
32
- config = options.delete(:config) || Dir.glob(File.join(base_dir, 'config', 'trinidad.{yml,rb}')).first
33
- if config and config = File.expand_path(config, base_dir)
34
- if yaml_configuration?(config)
35
- require 'yaml'
36
- require 'erb'
32
+ config = config_file(options[:web_app_dir])
33
+ if config && File.exist?(config)
34
+ if yaml = (File.extname(config) == '.yml')
35
+ require 'yaml'; require 'erb'
37
36
  config_options = YAML.load(ERB.new(File.read(config)).result(binding))
38
- options.deep_merge!(config_options.symbolize!)
39
37
  end
38
+ # NOTE: provided options should override configuration values :
39
+ Trinidad.configure(config_options, options) do
40
+ load config unless yaml # if not .yml assume it's ruby (.rb)
41
+ end
42
+ else
43
+ Trinidad.configure(options)
40
44
  end
41
-
42
- Trinidad.configure(options)
43
- if ruby_configuration?(config)
44
- load config
45
- end
46
-
47
- options
48
45
  end
49
46
  alias_method :load_configuration, :load!
50
47
 
51
- def yaml_configuration?(config)
52
- config && File.exist?(config) && config =~ /\.yml$/
53
- end
54
-
55
- def ruby_configuration?(config)
56
- config && File.exist?(config) && config =~ /\.rb$/
48
+ def config_file(base_dir = nil)
49
+ base_dir ||= Dir.pwd
50
+ if @config_file.nil? # false means do not use no config file
51
+ Dir.glob(File.join(base_dir, 'config', 'trinidad.{yml,rb}')).first
52
+ else
53
+ @config_file && File.expand_path(@config_file, base_dir)
54
+ end
57
55
  end
58
-
56
+
57
+ attr_writer :config_file
58
+
59
59
  def options_parser
60
+ require 'optparse'
60
61
  @parser ||= OptionParser.new do |opts|
61
62
  opts.banner = 'Trinidad server default options:'
62
63
  opts.separator ''
63
64
 
64
- opts.on('-d', '--dir WEB_APP_DIRECTORY', 'Web app directory path',
65
- "default: #{Dir.pwd}") do |v|
66
- default_options[:web_app_dir] = v
65
+ opts.on('-d', '--dir WEB_APP_DIRECTORY', 'web app directory path',
66
+ "default: #{Dir.pwd}") do |dir|
67
+ default_options[:web_app_dir] = dir
67
68
  end
68
69
 
69
- opts.on('-e', '--env ENVIRONMENT', 'Rails environment',
70
- "default: #{default_options[:environment]}") do |v|
71
- default_options[:environment] = v
70
+ opts.on('-e', '--env ENVIRONMENT', '(rails) environment',
71
+ "default: #{default_options[:environment]}") do |env|
72
+ default_options[:environment] = env
72
73
  end
73
74
 
74
- opts.on('-p', '--port PORT', 'Port to bind to',
75
- "default: #{default_options[:port]}") do |v|
76
- default_options[:port] = v
75
+ opts.on('-p', '--port PORT', 'port to bind to',
76
+ "default: #{default_options[:port]}") do |port|
77
+ default_options[:port] = port
77
78
  end
78
79
 
79
- opts.on('-c', '--context CONTEXT_PATH', 'The application context path',
80
- "default: #{default_options[:context_path]}") do |v|
81
- default_options[:context_path] = v
80
+ opts.on('-c', '--context CONTEXT_PATH', 'application context path',
81
+ "default: #{default_options[:context_path]}") do |path|
82
+ default_options[:context_path] = path
82
83
  end
83
84
 
84
- opts.on('--lib', '--jars LIBS_DIR', 'Directory containing jars used by the application',
85
- "default: #{default_options[:libs_dir]}") do |v|
86
- default_options[:libs_dir] = v
85
+ opts.on('--lib', '--jars LIBS_DIR', 'directory containing java jars used by the application',
86
+ "default: #{default_options[:libs_dir]}") do |dir|
87
+ default_options[:libs_dir] = dir
87
88
  end
88
89
 
89
- opts.on('--classes', '--classes CLASSES_DIR', 'Directory containing classes used by the application',
90
- "default: #{default_options[:classes_dir]}") do |v|
91
- default_options[:classes_dir] = v
90
+ opts.on('--classes', '--classes CLASSES_DIR', 'directory containing java classes used by the application',
91
+ "default: #{default_options[:classes_dir]}") do |dir|
92
+ default_options[:classes_dir] = dir
92
93
  end
93
94
 
94
- opts.on('-s', '--ssl [SSL_PORT]', 'Enable secure socket layout',
95
- "default port: 8443") do |v|
96
- ssl_port = v.nil? ? 8443 : v.to_i
97
- default_options[:ssl] = {:port => ssl_port}
95
+ opts.on('-s', '--ssl [SSL_PORT]', 'enable secure socket layout',
96
+ "default port: 8443") do |port|
97
+ default_options[:ssl] = { :port => (port || 8443).to_i }
98
98
  end
99
99
 
100
- opts.on('-a', '--ajp [AJP_PORT]', 'Enable ajp connections',
101
- "default port: 8009") do |v|
102
- ajp_port = v.nil? ? 8009 : v.to_i
103
- default_options[:ajp] = {:port => ajp_port}
100
+ opts.on('-a', '--ajp [AJP_PORT]', 'enable ajp connections (deprecated)',
101
+ "default port: 8009") do |port|
102
+ default_options[:ajp] = { :port => (port || 8009).to_i }
104
103
  end
105
104
 
106
- opts.on('-f', '--config [CONFIG_FILE]', 'Configuration file',
107
- "default: config/trinidad.yml") do |file|
108
- default_options[:config] = file || 'config/trinidad.yml'
105
+ opts.on('-f', '--config [CONFIG_FILE]', 'configuration file',
106
+ "default: config/trinidad.{yml,rb}") do |file|
107
+ self.config_file = file
109
108
  end
110
109
 
111
- opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file',
112
- 'default: config.ru') do |v|
113
- default_options[:rackup] = v || 'config.ru'
110
+ opts.on('-r', '--rackup [RACKUP_FILE]', 'rackup configuration file',
111
+ 'default: config.ru') do |rackup|
112
+ default_options[:rackup] = rackup || 'config.ru'
114
113
  end
115
114
 
116
- opts.on('--public', '--public DIRECTORY', 'Public directory', 'default: public') do |v|
117
- default_options[:public] = v
115
+ opts.on('--public', '--public DIRECTORY', 'public directory', 'default: public') do |public|
116
+ default_options[:public] = public
118
117
  end
119
118
 
120
- opts.on('-t', '--threadsafe', 'Threadsafe mode') do
119
+ opts.on('-t', '--threadsafe', 'force thread-safe mode') do
121
120
  default_options[:jruby_min_runtimes] = 1
122
121
  default_options[:jruby_max_runtimes] = 1
123
122
  end
124
123
 
125
- opts.on('--address', '--address ADDRESS', 'Trinidad host address', 'default: localhost') do |v|
126
- default_options[:address] = v
124
+ opts.on('--address', '--address ADDRESS', 'host address', 'default: localhost') do |address|
125
+ default_options[:address] = address
127
126
  end
128
127
 
129
- opts.on('-g', '--log LEVEL', 'Log level', 'default: INFO') do |v|
130
- default_options[:log] = v
128
+ opts.on('-g', '--log LEVEL', 'log level', 'default: INFO') do |log|
129
+ default_options[:log] = log
131
130
  end
132
131
 
133
132
  opts.on('-v', '--version', 'display the current version') do
@@ -137,7 +136,7 @@ module Trinidad
137
136
 
138
137
  opts.on('-l', '--load EXTENSION_NAMES', Array, 'load options for extensions') do |ext_names|
139
138
  ext_names.each do |ext|
140
- Trinidad::Extensions.configure_options_extensions({ext => {}}, opts, default_options)
139
+ Trinidad::Extensions.configure_options_extensions({ ext => {} }, opts, default_options)
141
140
  end
142
141
  end
143
142
 
@@ -148,12 +147,13 @@ module Trinidad
148
147
  opts.on('--monitor' '--monitor MONITOR_FILE', 'monitor file for hot deployments') do |monitor|
149
148
  default_options[:monitor] = monitor
150
149
  end
151
-
150
+
152
151
  opts.on('-h', '--help', 'display the help') do
153
152
  puts opts
154
153
  exit
155
154
  end
156
155
  end
157
156
  end
157
+
158
158
  end
159
159
  end