trinidad 1.4.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,9 +1,22 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec :name => "trinidad"
4
4
 
5
- # for the integration tests :
6
- group :test do
7
- gem "rails", "~> 3.2"
5
+ # NOTE: allows testing with various jar versions
6
+ if (jars = ENV['trinidad_jars']) && jars != 'false'
7
+ if jars =~ /\d\.\d\.\d/
8
+ # concrete version e.g. '1.0.8' or '>= 1.0.8'
9
+ gem 'trinidad_jars', jars
10
+ else
11
+ # pre-release version e.g. `export trinidad_jars=true`
12
+ gem 'trinidad_jars', :path => (jars == 'true' ? '.' : jars)
13
+ end
14
+ end
15
+
16
+ gem 'sinatra', :require => nil, :group => :test
17
+
18
+ group :integration do
19
+ gem "rails", "~> 3.2.8"
8
20
  gem "jruby-openssl"
21
+ #eval(File.read("spec/integration/rails32/Gemfile"), binding)
9
22
  end
data/History.txt CHANGED
@@ -1,3 +1,60 @@
1
+ == Trinidad 1.4.3 (2012-09-20)
2
+
3
+ * allow to keep (and configure) the jsp servlet (support for serving .jsp pages)
4
+ * decreased jruby.runtime.acquire.timeout default from 10 to 5 seconds
5
+ * removed Threads=MIN:MAX option from Rack::Handler (makes no sense right now)
6
+ * trinidad (CLI) :
7
+ - added --runtimes option to allow specifying pool size on command-line
8
+ - deprecated libs_dir and classes_dir added java_lib and java_classes
9
+ - deprecated --apps option and use the same name as in config --apps_base
10
+ - now prints some more accurate defaults that are used
11
+ * leverage Tomcat's default servlet for serving static asset files :
12
+ - use a customized default servlet to handle the public.root assets
13
+ - support for providing aliases (to achieve desired backward compatibility)
14
+ - support for allowing caching and tuning (asset) cache parameters
15
+ * allow absolute paths with :default_web_xml / :web_xml configuration option
16
+ * replace :libs_dir and :classes_dir with :java_lib and :java_classes options
17
+ (backwards compatible) with sensible defaults *lib/java* and *lib/java/classes*
18
+ * make sure application :work_dir is actually being set on the context
19
+ and change it by default to to [RAILS_ROOT]/tmp
20
+ * web application's :web_app_dir deprecated in favor of the :root_dir option
21
+ * make sure the rack servlet loads on startup by default
22
+ * allow init_params: to be configured with (rack/default) servlet options
23
+ * allow for default (servlet) overrides using default_servlet:
24
+ * better rack_servlet: configuration
25
+ - accepts a servlet instance (and assumes it is configured)
26
+ - 'rack' naming convention might be used to use custom servlet class
27
+ - support for servlet :mapping and :load_on_startup options
28
+ * fix async_supported: option not propagating correctly into servlet
29
+ * support for loading META-INF/context.xml from the (classes) class-path
30
+
31
+ Requires JRuby-Rack >= 1.1.10 and thus includes the following features :
32
+
33
+ - Rails 3.1+ `render stream: true` support with HTTP chunked encoding
34
+ - initial compatibility with Rails master (getting torwards 4.0.0.beta)
35
+ - all Rack applications now support pooling runtimes (not just Rails)
36
+ - better and more predictable application pool initialization
37
+ - support for fully leveraging the Servlet API for parameters/cookies
38
+ this is useful for Java integration cases when a servlet/filter consumes
39
+ the input stream before Rails (e.g. valves such as AccessLogValve).
40
+ it is an experimental feature that might change in the future and
41
+ currently requires setting 'jruby.rack.handler.env' param to 'servlet'
42
+
43
+ == Trinidad_jars 1.1.0 (2012-09-20)
44
+
45
+ * include java code compiled into trinidad-rb.jar for Trinidad
46
+ * otherwise same as previous version (1.0.7) uses Tomcat 7.0.30
47
+
48
+ == Trinidad 1.4.2 (2012-09-19) YANKED
49
+
50
+ == Trinidad_jars 1.0.7 (2012-09-12)
51
+
52
+ * Tomcat 7.0.30 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
53
+
54
+ == Trinidad_jars 1.0.6 (2012-08-21)
55
+
56
+ * Tomcat 7.0.29 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
57
+
1
58
  == Trinidad 1.4.1 (2012-08-17)
2
59
 
3
60
  * make sure file logging rotates correctly when file handler attempts rolling
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  == Trinidad
2
2
 
3
- Copyright (c) 2009-2012 David Calavera
3
+ Copyright (c) 2012 Team Trinidad and contributors http://github.com/trinidad
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
@@ -21,7 +21,8 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- == Additional Bundled Software
24
+ == Tomcat
25
25
 
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.
26
+ Apache Tomcat (Copyright 1999-2012 The Apache Software Foundation)
27
+ is licensed under the Apache License, Version 2.0.
28
+ See http://www.apache.org/licenses/LICENSE-2.0 for details.
data/README.md CHANGED
@@ -30,7 +30,7 @@ gem 'trinidad', :require => nil
30
30
 
31
31
  **Rails**
32
32
 
33
- If you have Trinidad in your Gemfile you can start it with `rails server`:
33
+ If you have Trinidad in your *Gemfile* you can start it with `rails server`:
34
34
 
35
35
  ```
36
36
  $ rails s trinidad
@@ -73,24 +73,41 @@ Or you can set Trinidad by default in your `config.ru` file:
73
73
  #\ -s trinidad
74
74
  ```
75
75
 
76
+ We do recommend to use the plain `trinidad` command for running applications
77
+ (in production), since it supports runtime pooling while the rackup mode does
78
+ not, it also provides you with better Java integration possibilities.
79
+
80
+ Also note that Trinidad does not mimic JRuby-Rack's behavior of starting a pool
81
+ for Rails but booting plain Rack applications in a thread-safe manner by
82
+ default (this is due backwards compatibility). Currently, runtime pooling is the
83
+ default with Trinidad and stays the same no matter the type of the application
84
+ you're running. We expect this default to most likely change in future versions
85
+ of Trinidad as thread-safe gets more adopted by the release of Rails 4.0.
86
+
76
87
  ## Configuration
77
88
 
78
89
  Trinidad allows you to configure parameters from the command line, the following
79
90
  is a list of the currently supported options (try `trinidad -h`):
80
91
 
81
92
  ```
82
- * -p, --port PORT => port to bind to.
83
- * -e, --env ENVIRONMENT => rails environment.
84
- * -c, --context CONTEXT => application context path.
85
- * --lib, --jars LIBS_DIR => directory containing jars.
86
- * --classes CLASSES_DIR => directory containing classes.
87
- * -r, --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
88
- * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
89
- * -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.
90
- * -l, --load EXTENSION_NAMES => load extensions to use their command line options.
91
- * --address HOST => set the server host.
92
- * -g, --log LEVEL => set the log level, default INFO.
93
- * --apps APPS_BASE_DIRECTORY => set the applications base directory.
93
+ * -d, --dir ROOT_DIR => web application root directory
94
+ * -e, --env ENVIRONMENT => rack (rails) environment
95
+ * --rackup [RACKUP_FILE] => rackup configuration file
96
+ * --public PUBLIC_DIR => web application public root
97
+ * -c, --context CONTEXT => application context path
98
+ * --monitor MONITOR_FILE => monitor for application re-deploys
99
+ * -t, --threadsafe => force thread-safe mode (use single runtime)
100
+ * --runtimes MIN:MAX => use given number of min/max jruby runtimes
101
+ * -f, --config [CONFIG_FILE] => configuration file
102
+ * --address ADDRESS => host address
103
+ * -p, --port PORT => port to bind to
104
+ * -s, --ssl [SSL_PORT] => enable secure socket layout
105
+ * -a, --ajp [AJP_PORT] => enable the AJP web protocol
106
+ * --java_lib LIB_DIR => contains .jar files used by the app
107
+ * --java_classes CLASSES_DIR => contains java classes used by the app
108
+ * -l, --load EXTENSION_NAMES => load options for extensions
109
+ * --apps_base APPS_BASE_DIR => set applications base directory
110
+ * -g, --log LEVEL => set logging level
94
111
  ```
95
112
 
96
113
  You can also specify a default *web.xml* to configure your web application.
@@ -128,6 +145,7 @@ configuration - the file `config/trinidad.rb` is loaded by default if exists.
128
145
  Trinidad.configure do |config|
129
146
  config.port = 4242
130
147
  config.address = '0.0.0.0'
148
+ #config[:custom] = 'custom'
131
149
  end
132
150
  ```
133
151
 
@@ -162,12 +180,57 @@ If this is not enough you can still configure a Java logging library e.g. SLF4J,
162
180
  just make sure you tell Trinidad to use it as well, if needed, using the
163
181
  **jruby.rack.logging** context parameter in *web.xml*.
164
182
 
183
+ ### Context Configuration
184
+
185
+ For slightly advanced (and "dirty" XML :)) application configuration Trinidad
186
+ also supports the exact same *context.xml* format as Tomcat. Each web app is
187
+ represented as a context instance and might be configured as such. You do not
188
+ need to repeat configuring the same parameters you have already setup with the
189
+ Trinidad configuration. This is meant to be mostly for those familiar with
190
+ Tomcat internals.
191
+ Currently the application's *context.xml* is expected to be located on the
192
+ class-path under your *[classes]/META-INF* directory.
193
+
194
+ Context Doc: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
195
+
196
+ ### Serving Assets
197
+
198
+ Trinidad uses Tomcat's built-in capabilities to server your public files.
199
+ We do recommend compiling assets up front and disabling the asset server (in
200
+ production) if you're using the asset pipeline in a Rails application.
201
+ If you do not put a web-server such as Apache in front of Trinidad you might
202
+ want to configure the resource caching (on by default for env != development)
203
+ for maximum performance e.g. by default it's configured as follows :
204
+
205
+ ```yml
206
+ ---
207
+ public:
208
+ root: public # same as the above "public: public" setting
209
+ cached: true # enable (in-memory) asset caching on for env != 'development'
210
+ cache_ttl: 5000 # cache TTL in millis (might want to increase this)
211
+ cache_max_size: 10240 # the maximum cache size in kB
212
+ cache_object_max_size: 512 # max size for a cached object (asset) in kB
213
+ #aliases: # allows to "link" other directories into the public root e.g. :
214
+ #/home: /var/local/www
215
+ ```
216
+
217
+ Note that this configuration applies to (server-side) resource caching on top
218
+ of the "public" file-system. You do not need to worry about client side caching,
219
+ it is handled out of the box with *ETag* and *Last-Modified* headers being set.
220
+
221
+ You might also "mount" file-system directories as aliases to your resources
222
+ root to be served by your application (as if they were in the public folder).
223
+
224
+ **NOTE:** In development mode if you ever happen to `rake assets:precompile`
225
+ make sure to remove your *public/assets* directory later, otherwise requests
226
+ such as **/assets/application.js?body=1.0** might not hit the Rails runtime.
227
+
165
228
  ## Hot Deployment
166
229
 
167
230
  Trinidad supports monitoring a file to reload applications, when the file
168
231
  *tmp/restart.txt* is updated (e.g. `touch tmp/restart.txt`), the server reloads
169
- the application the file belongs.
170
- The file monitor can be customized with the `monitor` configuration option.
232
+ the application the monitor file belongs to.
233
+ This monitor file can be customized with the `monitor` configuration option.
171
234
 
172
235
  Since version **1.4.0** Trinidad supports 2 reload strategies :
173
236
 
@@ -239,18 +302,27 @@ end
239
302
  Trinidad allows to extend itself with more (not just Tomcat) features,
240
303
  here is a list of the available extensions that are "officially supported":
241
304
 
242
- * Database Connection Pooling: http://github.com/trinidad/trinidad_dbpool_extension
243
- * Daemonize Trinidad, based on Akuma: http://github.com/trinidad/trinidad_daemon_extension
244
- * Init Services (for Unix and Windows), based on Commons Daemon: http://github.com/trinidad/trinidad_init_services
245
- * Logging, enhance Trinidad's logging system: http://github.com/trinidad/trinidad_logging_extension
246
- * Application and Server Lifecycle Management: http://github.com/trinidad/trinidad_lifecycle_extension
247
- * Trinidad's Management Console and REST API: http://github.com/trinidad/trinidad_sandbox_extension
248
- * Scheduler, based on Quartz: http://github.com/trinidad/trinidad_scheduler_extension
249
- * Valves - components inserted into the request pipeline (e.g. Access Log): http://github.com/trinidad/trinidad_valve_extension
305
+ * Database Connection Pooling:
306
+ http://github.com/trinidad/trinidad_dbpool_extension
307
+ * Daemonize Trinidad, based on Akuma:
308
+ http://github.com/trinidad/trinidad_daemon_extension
309
+ * Init Services (for Unix and Windows), based on Commons Daemon:
310
+ http://github.com/trinidad/trinidad_init_services
311
+ * Logging, enhance Trinidad's logging system:
312
+ http://github.com/trinidad/trinidad_logging_extension
313
+ * Application and Server Lifecycle Management:
314
+ http://github.com/trinidad/trinidad_lifecycle_extension
315
+ * Trinidad's Management Console and REST API:
316
+ http://github.com/trinidad/trinidad_sandbox_extension
317
+ * Scheduler, based on Quartz:
318
+ http://github.com/trinidad/trinidad_scheduler_extension
319
+ * Valves - components inserted into the request pipeline (e.g. Access Log):
320
+ http://github.com/trinidad/trinidad_valve_extension
250
321
 
251
322
  You can find further information on how to write extensions in the wiki:
252
323
  http://wiki.github.com/trinidad/trinidad/extensions
253
324
 
254
325
  ## Copyright
255
326
 
256
- Copyright (c) 2011-2012 David Calavera. See LICENSE for details.
327
+ Copyright (c) 2012 [Team Trinidad](https://github.com/trinidad).
328
+ See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.
data/Rakefile CHANGED
@@ -1,41 +1,101 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ begin
2
+ require 'bundler/gem_helper'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'bundler/gem_helper'
6
+ end
7
+
8
+ task :default => :spec
9
+
10
+ require 'rspec/core/rake_task'
11
+ RSpec::Core::RakeTask.new(:spec) do |spec|
12
+ spec.rspec_opts = ['--color', "--format documentation"]
13
+ end
3
14
 
4
- def version(file, constant)
5
- line = File.read(file)[/^\s*#{constant}\s*=\s*.*/]
6
- line.match(/.*#{constant}\s*=\s*['"](.*)['"]/)[1]
15
+ desc "Remove all build artifacts"
16
+ task :clear do
17
+ sh "rm -rf pkg/"
7
18
  end
19
+ task :clean => :clear
8
20
 
9
- def build(gemspec_file, gem_file)
10
- mkdir_p 'pkg'
11
- sh "gem build #{gemspec_file}"
12
- mv gem_file, 'pkg'
21
+ desc "Clear all jar artifacts"
22
+ task :clear_jars => [ 'tomcat:clear', 'tomcat-core:clear', 'trinidad-rb:clear' ] do
13
23
  end
24
+ task :clean_jars => :clear_jars
14
25
 
15
- def release(name, gem_file, version)
16
- unless `git branch` =~ /^\* master$/
17
- puts "You must be on the master branch to release!"
18
- exit!
26
+ ['trinidad', 'trinidad_jars'].each do |name|
27
+ gem_helper = Bundler::GemHelper.new(Dir.pwd, name)
28
+ def gem_helper.version_tag
29
+ "#{name}-#{version}" # override "v#{version}"
19
30
  end
20
- sh "git commit --allow-empty -a -m 'Release #{name} #{version}'"
21
- sh "git tag #{name}-#{version}"
22
- sh "git push origin master --tags"
23
- sh "gem push pkg/#{gem_file}"
24
- end
31
+ version = gem_helper.send(:version)
32
+ version_tag = gem_helper.version_tag
33
+ namespace name do
34
+ desc "Build #{name}-#{version}.gem into the pkg directory"
35
+ task('build') { gem_helper.build_gem }
25
36
 
26
- {
27
- :build => 'Build all Trinidad gems',
28
- :install => 'Install all Trinidad gems',
29
- :release => 'Release all Trinidad gems'
30
- }.each do |task, desc|
31
- desc desc
32
- task task => ["trinidad_jars:#{task}", "trinidad:#{task}"]
37
+ desc "Build and install #{name}-#{version}.gem into system gems"
38
+ task('install') { gem_helper.install_gem }
39
+
40
+ desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems"
41
+ task('release') { gem_helper.release_gem }
42
+ end
33
43
  end
34
44
 
35
- require 'rspec/core/rake_task'
45
+ TOMCAT_CORE_JAR = File.expand_path('../trinidad-libs/tomcat-core.jar', __FILE__)
46
+ TRINIDAD_RB_JAR = File.expand_path('../trinidad-libs/trinidad-rb.jar', __FILE__)
36
47
 
37
- RSpec::Core::RakeTask.new(:spec) do |spec|
38
- spec.rspec_opts = ['--color', "--format documentation"]
48
+ module TrinidadRakeHelpers
49
+
50
+ def javac(source_dir, target_dir, class_path = TOMCAT_CORE_JAR)
51
+ FileUtils.mkdir target_dir unless File.exist?(target_dir)
52
+ sh 'javac -Xlint:deprecation -Xlint:unchecked -g -source 1.6 -target 1.6 ' +
53
+ "-classpath #{class_path} -d #{target_dir} " +
54
+ Dir["#{source_dir}/**/*.java"].join(" ")
55
+ end
56
+
57
+ def jar(entries, jar_path)
58
+ work_dir = Dir.pwd
59
+ if entries.is_a?(String) && File.directory?(entries)
60
+ work_dir = entries
61
+ entries = Dir.entries(entries) - [ '.', '..' ]
62
+ end
63
+ Dir.chdir(work_dir) do
64
+ update = File.exist?(jar_path)
65
+ log "#{update ? 'updating' : 'creating'} #{jar_path}"
66
+ options = update ? '-uvf' : '-cvf'
67
+ %x{jar #{options} #{jar_path} #{entries.join(' ')}}
68
+ end
69
+ end
70
+
71
+ def log(msg)
72
+ puts msg
73
+ end
74
+
39
75
  end
40
76
 
41
- task :default => :spec
77
+ namespace :'trinidad-rb' do
78
+ include TrinidadRakeHelpers
79
+
80
+ TRINIDAD_RB_TARGET_DIR = File.expand_path('../target/trinidad-rb', __FILE__)
81
+
82
+ task :compile do
83
+ javac "src/trinidad-rb/java", TRINIDAD_RB_TARGET_DIR
84
+ end
85
+
86
+ task :jar => :compile do
87
+ rm TRINIDAD_RB_JAR if File.exist?(TRINIDAD_RB_JAR)
88
+ jar TRINIDAD_RB_TARGET_DIR, TRINIDAD_RB_JAR
89
+ end
90
+
91
+ task :clear do
92
+ rm_r TRINIDAD_RB_TARGET_DIR if File.exist?(TRINIDAD_RB_TARGET_DIR)
93
+ rm TRINIDAD_RB_JAR if File.exist?(TRINIDAD_RB_JAR)
94
+ end
95
+ task :clean => :clear
96
+
97
+ end
98
+
99
+ task :build => 'trinidad:build'
100
+ task :install => 'trinidad:install'
101
+ task :release => 'trinidad:release'
@@ -11,9 +11,7 @@ module Rack
11
11
  class Trinidad < Rack::Handler::Servlet
12
12
  def self.run(app, options={})
13
13
  opts = parse_options(options)
14
-
15
- servlet = create_servlet(app)
16
- opts[:servlet] = {:instance => servlet, :name => 'RackServlet'}
14
+ opts[:rack_servlet] = create_servlet(app)
17
15
 
18
16
  ::Trinidad::CommandLineParser.load(opts)
19
17
  server = ::Trinidad::Server.new
@@ -25,14 +23,14 @@ module Rack
25
23
  {
26
24
  "Host=HOST" => "Hostname to listen on (default: localhost)",
27
25
  "Port=PORT" => "Port to listen on (default: 8080)",
28
- "Threads=MIN:MAX" => "min:max threads to use (default 1:1, threadsafe)",
26
+ #"Threads=MIN:MAX" => "min:max runtimes to use (default 1:1, threadsafe)",
29
27
  }
30
28
  end
31
29
 
32
30
  def self.parse_options(options = {})
33
31
  # some libs use :Port, :port and :Host, :host, unify this
34
32
  opts = {}
35
- options.each {|k, v| opts[k.to_s.downcase.to_sym] = v}
33
+ options.each { |k, v| opts[k.to_s.downcase.to_sym] = v }
36
34
 
37
35
  # this is rack's configuration file but also the trinidad's configuration.
38
36
  # Removing it we allow to load trinidad's default configuration.
data/lib/trinidad.rb CHANGED
@@ -1,17 +1,18 @@
1
1
  require 'java'
2
2
 
3
3
  require 'jruby-rack'
4
+ require 'trinidad/jars'
4
5
 
5
6
  require 'trinidad/version'
6
- require 'trinidad/extensions'
7
+
7
8
  require 'trinidad/configuration'
8
9
  require 'trinidad/command_line_parser'
9
- require 'trinidad/jars'
10
+ require 'trinidad/extensions'
10
11
  require 'trinidad/logging'
11
12
  require 'trinidad/server'
13
+ require 'trinidad/web_app'
12
14
  require 'trinidad/lifecycle/base'
13
15
  require 'trinidad/lifecycle/host'
14
16
  require 'trinidad/lifecycle/web_app/shared'
15
17
  require 'trinidad/lifecycle/web_app/default'
16
18
  require 'trinidad/lifecycle/web_app/war'
17
- require 'trinidad/web_app'