trinidad 1.5.0.B1 → 1.5.0.B2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +21 -8
- data/History.md +55 -0
- data/LICENSE +1 -1
- data/README.md +24 -20
- data/Rakefile +17 -8
- data/lib/trinidad.rb +1 -0
- data/lib/trinidad/configuration.rb +46 -11
- data/lib/trinidad/lifecycle/host.rb +5 -4
- data/lib/trinidad/lifecycle/host/rolling_reload.rb +9 -5
- data/lib/trinidad/lifecycle/web_app/shared.rb +1 -0
- data/lib/trinidad/logging.rb +27 -44
- data/lib/trinidad/server.rb +15 -4
- data/lib/trinidad/version.rb +1 -1
- data/lib/trinidad/web_app.rb +17 -11
- data/rakelib/tomcat.rake +10 -10
- data/trinidad.gemspec +3 -3
- metadata +36 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d42b0b5a750187bec38027af191d746359b4b920
|
4
|
+
data.tar.gz: 72ea1bd9f167bdf9393835dff38421ae3412f81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafb64f115d6305e00dc4a6b203714721d1a9e3a14a1437ea8f1aa7fb8e96bf673ae6ee820f799ac3914374ab542e8d86aaea7d87d0ae36f76e0732dffc6146a
|
7
|
+
data.tar.gz: dd4e382b8d8a5a4ee69d83df8c9a12d2c7199f2b8459de127c96a0818169e2d7491877e7a0e6e85b1fa43107abe38cf95861ea8fb7cd41eeadac3056b17132c9
|
data/Gemfile
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gemspec :name =>
|
3
|
+
gemspec :name => 'trinidad'
|
4
4
|
|
5
5
|
# NOTE: allows testing with various jar versions
|
6
|
-
if (jars = ENV['
|
6
|
+
if (jars = ENV['TRINIDAD_JARS_VERSION']) && jars != 'false'
|
7
7
|
if jars =~ /\d\.\d\.\d/
|
8
8
|
# concrete version e.g. '1.0.8' or '>= 1.0.8'
|
9
9
|
gem 'trinidad_jars', jars
|
10
10
|
else
|
11
|
-
# pre-release version e.g. `export
|
12
|
-
gem 'trinidad_jars', :path => (jars == 'true' ? '.' : jars)
|
11
|
+
# pre-release version e.g. `export TRINIDAD_JARS_VERSION=local`
|
12
|
+
gem 'trinidad_jars', :path => (jars == 'true' || jars == 'local' ? '.' : jars)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
gem 'rake', '
|
16
|
+
gem 'rake', '~> 10.4.2', :require => nil, :groups => [ :development, :test ]
|
17
|
+
|
17
18
|
group :development do
|
18
19
|
jruby_version = ENV['JRUBY_VERSION']
|
19
20
|
jruby_version = JRUBY_VERSION if jruby_version == 'current'
|
20
21
|
jruby_version ||= '1.6.8' # by default compiling against JRuby 1.6.8
|
21
22
|
gem 'jruby-jars', jruby_version, :require => nil # only for _javac_
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
25
|
+
if jruby_rack_version = ENV['JRUBY_RACK_VERSION']
|
26
|
+
gem 'jruby-rack', jruby_rack_version, :require => false
|
26
27
|
end
|
27
28
|
|
28
29
|
group :integration do
|
@@ -36,6 +37,18 @@ group :integration do
|
|
36
37
|
else
|
37
38
|
gem 'rails', :require => nil, :group => :test
|
38
39
|
end
|
40
|
+
if RUBY_VERSION.index('1.8') == 0
|
41
|
+
gem 'i18n', '< 0.7', :require => nil, :group => :test
|
42
|
+
gem 'sprockets', '< 3.0', :require => nil, :group => :test
|
43
|
+
gem 'mime-types', '< 2.3', :require => nil, :group => :test
|
44
|
+
elsif RUBY_VERSION.index('1.9.2') == 0
|
45
|
+
gem 'i18n', '< 0.7', :require => nil, :group => :test
|
46
|
+
gem 'sprockets', '< 3.0', :require => nil, :group => :test
|
47
|
+
gem 'mime-types', '< 3.0', :require => nil, :group => :test
|
48
|
+
end
|
49
|
+
if RUBY_VERSION < '2.0'
|
50
|
+
gem 'rack-cache', '< 1.3.0', :require => nil, :group => :test
|
51
|
+
end
|
39
52
|
gem 'jruby-openssl' if JRUBY_VERSION < '1.7.0'
|
40
53
|
# eval(File.read("spec/integration/rails32/Gemfile"), binding)
|
41
54
|
end
|
data/History.md
CHANGED
@@ -1,3 +1,58 @@
|
|
1
|
+
## trinidad 1.5.0.B2 (2016-07-14)
|
2
|
+
|
3
|
+
* default to async_supported: true style servlet configuration
|
4
|
+
* assume thread-safe by default and avoid config.threadsafe! detection in Rails
|
5
|
+
* improve JRuby 9K compatibility - avoid setting jruby.compat.version parameter
|
6
|
+
* fixes for rolling reload when context has been destroyed (see #133)
|
7
|
+
* support setting `:keystore_type` (for SSL)
|
8
|
+
* handle auto-loading of `Trinidad::CommandLineParser` constant for init service's
|
9
|
+
Trinidad::Daemon backwards-compatibility (see https://github.com/trinidad/trinidad_init_services/issues/41)
|
10
|
+
* support for running fully on Java 8 (class sun.security.tools.KeyTool seems gone)
|
11
|
+
|
12
|
+
## trinidad_jars 1.5.1 (2016-07-14)
|
13
|
+
|
14
|
+
* adjust (timer) cleanup for newer pg-jdbc driver versions
|
15
|
+
|
16
|
+
* Tomcat 7.0.64 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
17
|
+
|
18
|
+
## trinidad_jars 1.5.0 (2016-07-13)
|
19
|
+
|
20
|
+
* Tomcat 7.0.59 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
21
|
+
|
22
|
+
## trinidad_jars 1.4.2 (2015-10-09)
|
23
|
+
|
24
|
+
* Tomcat 7.0.57 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
25
|
+
* workaround for postgres reloading issues (#133) ... affects 1.5.0 only
|
26
|
+
|
27
|
+
## trinidad_jars 1.4.1 (2015-05-01)
|
28
|
+
|
29
|
+
* Tomcat 7.0.55 https://tomcat.apache.org/security-7.html#Fixed_in_Apache_Tomcat_7.0.55
|
30
|
+
fixes multiple security vulnerabilities since Tomcat 7.0.50
|
31
|
+
* do potential MariaDB driver cleanup (an alternative for the MySQL official driver)
|
32
|
+
* updated JarScanner internals so we're compilant
|
33
|
+
|
34
|
+
## trinidad 1.5.0.B1 (2014-03-27)
|
35
|
+
|
36
|
+
* make sure the context.name does include the original name (after reload)
|
37
|
+
* set server's parent class-loader for Class.forName to work better from Tomcat
|
38
|
+
* add the jruby-rack.jar to web-app's loader instead of using the one loaded
|
39
|
+
* start defaulting to "sensible" thread-safe
|
40
|
+
in development/test mode we shall start the same (thread-safe) way as in production
|
41
|
+
* set "reloader" (java) thread name for easier identification
|
42
|
+
* handle `address: *` since it broke on adding a JMX bean with * in it's name (which is not a valid one)
|
43
|
+
* allow to disable (inherited) web-app extension by specifying `name: false`
|
44
|
+
* remove some of the 'old' deprecated methods/configuration
|
45
|
+
* class-loader kung-fu to get thigns right towards leak free applications ...
|
46
|
+
* we're still binding by default to localhost/127.0.0.1 - change to '*' (#119)
|
47
|
+
|
48
|
+
## trinidad_jars 1.4.0 (2014-03-27)
|
49
|
+
|
50
|
+
* Tomcat 7.0.50 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
51
|
+
* a "faster" (default) JarScanner for Rack/Rails applications
|
52
|
+
based on TC's StandardJarScanner implementation
|
53
|
+
* an extended (default) web-app loader (to handle JRuby specific "leaks")
|
54
|
+
as well as some MySQL and PostgreSQL JDBC driver specific cleanup
|
55
|
+
|
1
56
|
## trinidad 1.4.6 (2013-12-28)
|
2
57
|
|
3
58
|
* default :port for SSL is now (a more Ruby-sh) 3443
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
== Trinidad
|
2
2
|
|
3
|
-
Copyright (c) 2014 Team Trinidad and contributors
|
3
|
+
Copyright (c) 2014-2016 Team Trinidad and contributors
|
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
|
data/README.md
CHANGED
@@ -19,12 +19,16 @@ Trinidad's goals with bringing Tomcat into JRuby land are mostly the following :
|
|
19
19
|
## Installation
|
20
20
|
|
21
21
|
[![gem version](https://badge.fury.io/rb/trinidad.png)](http://rubygems.org/gems/trinidad)
|
22
|
+
[![dependency status](https://gemnasium.com/trinidad/trinidad.png)][1]
|
22
23
|
|
23
24
|
```
|
24
25
|
$ jruby -S gem install trinidad
|
25
26
|
```
|
26
27
|
|
27
|
-
|
28
|
+
**NOTE:** please use **1.5.0.B2** `gem install trinidad --pre`, esp. on JRuby 9K,
|
29
|
+
as Trinidad 1.4 will no longer receive Tomcat (7.0.x) security updates.
|
30
|
+
|
31
|
+
Trinidad 1.4 requires (and supports) JRuby 1.6.8 or later (latest 1.7.x recommended).
|
28
32
|
|
29
33
|
## Quick Start
|
30
34
|
|
@@ -46,9 +50,9 @@ and than run `trinidad` - keep in mind a server is not an application dependency
|
|
46
50
|
|
47
51
|
### Rails
|
48
52
|
|
49
|
-
Trinidad supports the same Rails version as the JRuby-Rack it founds (or is
|
50
|
-
specified/locked in your *Gemfile*), which
|
51
|
-
|
53
|
+
Trinidad supports the same Rails version as the JRuby-Rack it founds on (or is
|
54
|
+
specified/locked in your *Gemfile*), which are **4.x**, **3.x** and even **2.3**
|
55
|
+
for JRuby-Rack 1.1.x (and the up coming 1.2). Merb is not supported.
|
52
56
|
|
53
57
|
```
|
54
58
|
$ trinidad
|
@@ -80,7 +84,7 @@ configure do
|
|
80
84
|
end
|
81
85
|
```
|
82
86
|
|
83
|
-
###
|
87
|
+
### Rack
|
84
88
|
|
85
89
|
Trinidad auto-detects a plain-old Rack application (if there's a *config.ru*) :
|
86
90
|
|
@@ -106,16 +110,17 @@ the same way as JRuby-Rack (since it boots all applications), that is :
|
|
106
110
|
- otherwise the rack (gem) version might be specified using a magic comment in
|
107
111
|
*config.ru* as `# rack.version: ~>1.4.0` (or the latest installed gem is used)
|
108
112
|
|
109
|
-
**NOTE:** We
|
113
|
+
**NOTE:** We recommend to use the plain `trinidad` mode for running apps
|
110
114
|
(in production), since it supports runtime pooling while the "rackup" mode does
|
111
115
|
not, it also provides you with better Java integration possibilities.
|
112
116
|
|
113
117
|
Also note that Trinidad does not mimic JRuby-Rack's (1.1.x) backwards compatible
|
114
118
|
behavior of starting a pool for Rails but booting a thread-safe runtime for
|
115
|
-
plain Rack applications by default.
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
plain Rack applications by default. Runtime pooling is the default with Trinidad
|
120
|
+
**1.4** and stays the same no matter the type of the application. This has
|
121
|
+
**changed in Trinidad 1.5** and it assumes thread-safe applications by default.
|
122
|
+
|
123
|
+
All major rack versions (< 2.0) are expected to be working fine with Trinidad.
|
119
124
|
|
120
125
|
## Configuration
|
121
126
|
|
@@ -285,7 +290,7 @@ failed releasing memory with reloads. This has been fixed in **1.5.0** please
|
|
285
290
|
consider updating, it is meant to be backwards compatible.
|
286
291
|
|
287
292
|
If you're on Java 6 you will likely need to tune your JAVA_OPTS / JRUBY_OPTS
|
288
|
-
for the JVM to do class unloading (consult the [wiki][] for more information) :
|
293
|
+
for the JVM to do class unloading (consult the [wiki][6] for more information) :
|
289
294
|
```
|
290
295
|
JRUBY_OPTS="$JRUBY_OPTS -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled"
|
291
296
|
```
|
@@ -387,20 +392,19 @@ You can find further information on how to write extensions in the [wiki][5].
|
|
387
392
|
|
388
393
|
## Support
|
389
394
|
|
390
|
-
*
|
391
|
-
*
|
392
|
-
*
|
393
|
-
*
|
394
|
-
* IRC [Channel on FreeNode][3]: #trinidad (or ask in #jruby)
|
395
|
+
* ask us for help on [gitter][2] or use [SO][3] ... we shall get notified
|
396
|
+
* we're also on the JRuby mailing List: http://wiki.jruby.org/MailingLists
|
397
|
+
* and the #jruby IRC [channel](http://webchat.freenode.net/?channels=jruby)
|
398
|
+
* please report issues at: https://github.com/trinidad/trinidad/issues
|
395
399
|
|
396
400
|
## Copyright
|
397
401
|
|
398
|
-
Copyright (c)
|
402
|
+
Copyright (c) 2016 [Team Trinidad](https://github.com/trinidad).
|
399
403
|
See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.
|
400
404
|
|
401
|
-
[
|
402
|
-
[
|
403
|
-
[3]: http://
|
405
|
+
[1]: https://gemnasium.com/trinidad/trinidad
|
406
|
+
[2]: https://gitter.im/trinidad
|
407
|
+
[3]: http://stackoverflow.com/questions/tagged/jruby
|
404
408
|
[4]: http://tomcat.apache.org/tomcat-7.0-doc/config/host.html
|
405
409
|
[5]: https://github.com/trinidad/trinidad/wiki/extensions
|
406
410
|
[6]: https://github.com/trinidad/trinidad/wiki/JOPTS
|
data/Rakefile
CHANGED
@@ -26,11 +26,8 @@ task :clean_jars => :clear_jars
|
|
26
26
|
|
27
27
|
['trinidad', 'trinidad_jars'].each do |name|
|
28
28
|
gem_helper = Bundler::GemHelper.new(Dir.pwd, name)
|
29
|
-
def gem_helper.version_tag
|
30
|
-
|
31
|
-
end
|
32
|
-
version = gem_helper.send(:version)
|
33
|
-
version_tag = gem_helper.version_tag
|
29
|
+
def gem_helper.version_tag; "#{name}-#{version}" end
|
30
|
+
version = gem_helper.send(:version); version_tag = gem_helper.version_tag
|
34
31
|
namespace name do
|
35
32
|
desc "Build #{name}-#{version}.gem into the pkg directory"
|
36
33
|
task('build') { gem_helper.build_gem }
|
@@ -42,6 +39,18 @@ task :clean_jars => :clear_jars
|
|
42
39
|
task('release') { gem_helper.release_gem }
|
43
40
|
end
|
44
41
|
end
|
42
|
+
unless Bundler::GemHelper.method_defined?(:release_gem)
|
43
|
+
Bundler::GemHelper.send :define_method, :release_gem do
|
44
|
+
guard_clean
|
45
|
+
tag_version unless already_tagged?
|
46
|
+
built_gem_path = build_gem
|
47
|
+
rubygem_push(built_gem_path) if gem_push?
|
48
|
+
end
|
49
|
+
Bundler::GemHelper.send :define_method, :install_gem do
|
50
|
+
built_gem_path = build_gem
|
51
|
+
install_gem(built_gem_path)
|
52
|
+
end
|
53
|
+
end
|
45
54
|
|
46
55
|
TOMCAT_CORE_JAR = File.expand_path('../trinidad-libs/tomcat-core.jar', __FILE__)
|
47
56
|
TRINIDAD_RB_JAR = File.expand_path('../trinidad-libs/trinidad-rb.jar', __FILE__)
|
@@ -52,9 +61,9 @@ module TrinidadRakeHelpers
|
|
52
61
|
source = '1.6'; target = '1.6' # java-compiler settings
|
53
62
|
FileUtils.mkdir target_dir unless File.exist?(target_dir)
|
54
63
|
class_path = class_path.join(':') unless class_path.is_a?(String)
|
55
|
-
sh "javac -Xlint:deprecation -Xlint:unchecked "
|
56
|
-
" -g -source #{source} -target #{target} "
|
57
|
-
" -classpath #{class_path} -d #{target_dir} "
|
64
|
+
sh "javac -Xlint:deprecation -Xlint:unchecked " +
|
65
|
+
" -g -source #{source} -target #{target} " +
|
66
|
+
" -classpath #{class_path} -d #{target_dir} " +
|
58
67
|
Dir["#{source_dir}/**/*.java"].join(" ")
|
59
68
|
end
|
60
69
|
|
data/lib/trinidad.rb
CHANGED
@@ -34,10 +34,11 @@ module Trinidad
|
|
34
34
|
|
35
35
|
DEFAULTS = {
|
36
36
|
:environment => 'development',
|
37
|
-
:context_path => '
|
37
|
+
:context_path => '', # / root path
|
38
38
|
:public => 'public',
|
39
39
|
:java_lib => 'lib/java',
|
40
40
|
:default_web_xml => 'config/web.xml',
|
41
|
+
:async_supported => true,
|
41
42
|
:trap => true
|
42
43
|
}
|
43
44
|
|
@@ -73,17 +74,51 @@ module Trinidad
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
KEYS = Hash.[]( # { :port => nil, :address => nil, ... }
|
78
|
+
[ :port, :address, :environment, :context_path,
|
79
|
+
:java_lib, :java_classes, :default_web_xml,
|
80
|
+
:jruby_min_runtimes, :jruby_max_runtimes, :jruby_compat_version,
|
81
|
+
:rackup, :public, :hosts, :rack_servlet, :default_servlet, :jsp_servlet,
|
82
|
+
:http, :ajp, :ssl, :https, :extensions,
|
83
|
+
:apps_base, :web_apps, :web_app_dir,
|
84
|
+
:monitor, :reload_strategy, :log, :trap ].each_slice(1).to_a)
|
85
|
+
private_constant :KEYS rescue nil
|
86
|
+
|
87
|
+
def public; self[:public] end
|
88
|
+
def public=(value); self[:public] = value end
|
89
|
+
|
90
|
+
def trap; self[:trap] end
|
91
|
+
def trap=(value); self[:trap] = value end
|
92
|
+
|
93
|
+
def method_missing(method, *args, &block)
|
94
|
+
if method[-1].eql? '='
|
95
|
+
if KEYS.key?(method = method[0...-1].to_sym)
|
96
|
+
if args.size != 1
|
97
|
+
raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1)"
|
98
|
+
end
|
99
|
+
return self[method] = args[0]
|
100
|
+
end
|
101
|
+
else
|
102
|
+
return self[method] if KEYS.key?(method)
|
103
|
+
end
|
104
|
+
super
|
105
|
+
end
|
106
|
+
|
107
|
+
def respond_to_missing?(method, include_private = false)
|
108
|
+
KEYS.key?(method) || super
|
109
|
+
end
|
110
|
+
|
111
|
+
# @deprecated
|
112
|
+
def servlet
|
113
|
+
Helpers.deprecated('configuration option :servlet, use :rack_servlet')
|
114
|
+
self[:servlet]
|
115
|
+
end
|
116
|
+
|
117
|
+
# @deprecated
|
118
|
+
def servlet=(value)
|
119
|
+
Helpers.deprecated('configuration option :servlet, use :rack_servlet')
|
120
|
+
self[:servlet] = value
|
85
121
|
end
|
86
|
-
# TODO deprecate servlet
|
87
122
|
|
88
123
|
# @private
|
89
124
|
def self.symbolize_options(options)
|
@@ -59,9 +59,10 @@ module Trinidad
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def init_monitors
|
62
|
-
|
63
|
-
monitor = app_holder.monitor
|
64
|
-
|
62
|
+
app_holders.each do |app_holder|
|
63
|
+
monitor = app_holder.monitor
|
64
|
+
opts = 'w+'
|
65
|
+
if ! File.exist?(dir = File.dirname(monitor)) # waR?
|
65
66
|
Dir.mkdir dir
|
66
67
|
elsif File.exist?(monitor)
|
67
68
|
opts = 'r'
|
@@ -73,7 +74,7 @@ module Trinidad
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def check_monitors
|
76
|
-
|
77
|
+
app_holders.each do |app_holder|
|
77
78
|
# double check monitor, capistrano removes it temporarily
|
78
79
|
unless File.exist?(monitor = app_holder.monitor)
|
79
80
|
sleep(0.5)
|
@@ -75,11 +75,15 @@ module Trinidad
|
|
75
75
|
new_context = event.lifecycle
|
76
76
|
new_context.remove_lifecycle_listener(self) # GC old context
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
if @old_context.state_name =~ /DESTROYED/i
|
79
|
+
logger.debug "Old context for [#{@old_context.path}] is already destroyed"
|
80
|
+
@old_context.work_dir = nil
|
81
|
+
else
|
82
|
+
logger.debug "Stopping the old context for [#{@old_context.path}]"
|
83
|
+
@old_context.stop
|
84
|
+
@old_context.work_dir = nil # make sure it's not deleted
|
85
|
+
@old_context.destroy
|
86
|
+
end
|
83
87
|
# NOTE: name might not be changed once added to a parent
|
84
88
|
#new_context.name = @old_context.name
|
85
89
|
super
|
data/lib/trinidad/logging.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
require 'jruby'
|
2
|
-
require 'fileutils'
|
3
2
|
|
4
3
|
module Trinidad
|
5
4
|
module Logging
|
6
5
|
|
6
|
+
# @private
|
7
7
|
JUL = Java::JavaUtilLogging
|
8
|
+
# @private
|
8
9
|
LogFactory = Java::OrgApacheJuliLogging::LogFactory
|
9
10
|
|
11
|
+
# A message formatter only prints the log message (and the thrown value).
|
12
|
+
# @private
|
13
|
+
MessageFormatter = Java::RbTrinidadLogging::MessageFormatter
|
14
|
+
# @private
|
15
|
+
DefaultFormatter = Java::RbTrinidadLogging::DefaultFormatter
|
16
|
+
|
10
17
|
@@configured = nil
|
11
18
|
|
12
|
-
# Configure the "global"
|
19
|
+
# Configure the ("global") logging sub-system.
|
20
|
+
# If invoked twice, does only actually configure once.
|
13
21
|
def self.configure(log_level = nil)
|
14
22
|
return false if @@configured
|
15
23
|
@@configured = true
|
@@ -17,7 +25,9 @@ module Trinidad
|
|
17
25
|
root_logger = JUL::Logger.getLogger('')
|
18
26
|
level = parse_log_level(log_level, :INFO)
|
19
27
|
|
20
|
-
|
28
|
+
runtime_out = JRuby.runtime.out
|
29
|
+
runtime_err = JRuby.runtime.err
|
30
|
+
out_handler = new_console_handler runtime_out
|
21
31
|
out_handler.formatter = console_formatter
|
22
32
|
|
23
33
|
root_logger.synchronized do
|
@@ -26,10 +36,10 @@ module Trinidad
|
|
26
36
|
end
|
27
37
|
|
28
38
|
root_logger.add_handler(out_handler)
|
29
|
-
if
|
30
|
-
|
39
|
+
if runtime_out != Java::JavaLang::System.out ||
|
40
|
+
runtime_err != Java::JavaLang::System.err
|
31
41
|
# NOTE: only add err handler if customized STDOUT or STDERR :
|
32
|
-
err_handler = new_console_handler
|
42
|
+
err_handler = new_console_handler runtime_err
|
33
43
|
err_handler.formatter = console_formatter
|
34
44
|
err_handler.level = level.intValue > JUL::Level::WARNING.intValue ?
|
35
45
|
level : JUL::Level::WARNING # only >= WARNING on STDERR
|
@@ -43,7 +53,7 @@ module Trinidad
|
|
43
53
|
root_logger
|
44
54
|
end
|
45
55
|
|
46
|
-
# Force logging
|
56
|
+
# Force logging re-configuration.
|
47
57
|
# @see #configure
|
48
58
|
def self.configure!(log_level = nil)
|
49
59
|
( @@configured = false ) || configure(log_level)
|
@@ -114,12 +124,17 @@ module Trinidad
|
|
114
124
|
def self.parse_log_level(log_level, default = nil)
|
115
125
|
log_level = log_level && log_level.to_s.upcase
|
116
126
|
unless JUL::Level.constants.find { |level| level.to_s == log_level }
|
117
|
-
log_level
|
118
|
-
|
119
|
-
|
120
|
-
|
127
|
+
case log_level
|
128
|
+
when 'ERROR' then log_level = 'SEVERE'
|
129
|
+
when 'WARN' then log_level = 'WARNING'
|
130
|
+
when 'DEBUG' then log_level = 'FINE'
|
131
|
+
end # try mapping common level names to JUL names
|
132
|
+
log_level ||= default ? default.to_s.upcase : nil
|
121
133
|
end
|
122
134
|
JUL::Level.parse(log_level) if log_level
|
135
|
+
rescue => e
|
136
|
+
JUL::Logger.getLogger('').warning "Failed to parse log level #{log_level.inspect} (#{e})"
|
137
|
+
JUL::Level.const_get(default)
|
123
138
|
end
|
124
139
|
|
125
140
|
def self.set_log_level(logger, level)
|
@@ -137,19 +152,11 @@ module Trinidad
|
|
137
152
|
'org.apache.catalina.core.StandardService',
|
138
153
|
'org.apache.catalina.core.StandardEngine',
|
139
154
|
'org.apache.catalina.startup.ContextConfig',
|
140
|
-
#'org.apache.coyote.http11.Http11Protocol',
|
141
|
-
'org.apache.catalina.core.ApplicationContext',
|
142
|
-
#'org.apache.catalina.core.AprLifecycleListener',
|
143
|
-
'org.apache.catalina.loader.WebappClassLoader',
|
144
|
-
'org.apache.tomcat.websocket.server.WsSci',
|
145
155
|
]
|
146
156
|
for name in logger_names
|
147
157
|
logger = JUL::Logger.getLogger(name)
|
148
158
|
set_log_level(logger, level) if logger
|
149
159
|
end
|
150
|
-
|
151
|
-
#set_log_level(JUL::Logger.getLogger('rb.trinidad.context.DefaultLoader'), JUL::Level::FINEST)
|
152
|
-
|
153
160
|
end
|
154
161
|
|
155
162
|
def self.web_app_context_param(web_app, context, name)
|
@@ -174,32 +181,8 @@ module Trinidad
|
|
174
181
|
handler
|
175
182
|
end
|
176
183
|
|
184
|
+
# @private
|
177
185
|
FileHandler = Java::RbTrinidadLogging::FileHandler
|
178
186
|
|
179
|
-
# We're truly missing a #formatThrown exception helper method.
|
180
|
-
JUL::Formatter.class_eval do # :nodoc:
|
181
|
-
|
182
|
-
LINE_SEP = java.lang.System.getProperty("line.separator")
|
183
|
-
|
184
|
-
protected
|
185
|
-
def formatThrown(record)
|
186
|
-
if record.thrown
|
187
|
-
writer = java.io.StringWriter.new(1024)
|
188
|
-
print_writer = java.io.PrintWriter.new(writer)
|
189
|
-
print_writer.println
|
190
|
-
record.thrown.printStackTrace(print_writer)
|
191
|
-
print_writer.close
|
192
|
-
return writer.toString
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
# A message formatter only prints the log message (and the thrown value).
|
199
|
-
MessageFormatter = Java::RbTrinidadLogging::MessageFormatter
|
200
|
-
|
201
|
-
DefaultFormatter = Java::RbTrinidadLogging::DefaultFormatter
|
202
|
-
|
203
187
|
end
|
204
|
-
LogFormatter = Logging::DefaultFormatter # backwards compatibility
|
205
188
|
end
|
data/lib/trinidad/server.rb
CHANGED
@@ -176,6 +176,7 @@ module Trinidad
|
|
176
176
|
options[:keystoreFile] ||= keystore_file
|
177
177
|
end
|
178
178
|
options[:keystorePass] ||= options.delete(:keystore_pass) if options.key?(:keystore_pass)
|
179
|
+
options[:keystoreType] ||= options.delete(:keystore_type) if options.key?(:keystore_type)
|
179
180
|
# handle "custom" alternative SSL (casing) options :
|
180
181
|
options[:SSLEnabled] = options.delete(:ssl_enabled) || true # always true
|
181
182
|
options[:SSLCertificateFile] ||= options.delete(:ssl_certificate_file) if options.key?(:ssl_certificate_file)
|
@@ -225,7 +226,8 @@ module Trinidad
|
|
225
226
|
context = begin
|
226
227
|
host.start_children = start unless start.nil?
|
227
228
|
# public Context addWebapp(Host host, String url, String name, String docBase)
|
228
|
-
|
229
|
+
context_path = web_app.context_path; context_path = '' if context_path == '/'
|
230
|
+
tomcat.addWebapp(host, context_path, web_app.context_name, web_app.root_dir)
|
229
231
|
rescue Java::JavaLang::IllegalArgumentException => e
|
230
232
|
if e.message =~ /addChild\:/
|
231
233
|
context_name = web_app.context_name
|
@@ -388,9 +390,11 @@ module Trinidad
|
|
388
390
|
end if web_apps
|
389
391
|
end
|
390
392
|
|
393
|
+
Tomcat::StandardHost.send :field_writer, :appBase
|
394
|
+
|
391
395
|
def create_host(app_base, host_config, tomcat = @tomcat)
|
392
396
|
host = Tomcat::StandardHost.new
|
393
|
-
host.
|
397
|
+
host.appBase = nil # reset default app_base
|
394
398
|
host.deployXML = false # disabled by default
|
395
399
|
setup_host(app_base, host_config, host)
|
396
400
|
tomcat.engine.add_child host if tomcat
|
@@ -572,7 +576,7 @@ module Trinidad
|
|
572
576
|
|
573
577
|
key_tool_args = [ "-genkey",
|
574
578
|
"-alias", "localhost",
|
575
|
-
"-dname", dname = "CN=localhost,
|
579
|
+
"-dname", dname = "CN=localhost,OU=Trinidad,O=Trinidad,C=ES",
|
576
580
|
"-keyalg", "RSA",
|
577
581
|
"-validity", "365",
|
578
582
|
"-storepass", "key",
|
@@ -583,7 +587,14 @@ module Trinidad
|
|
583
587
|
logger.info "Generating a (default) keystore for localhost #{dname.inspect} at " <<
|
584
588
|
"#{file.canonical_path} (password: '#{pass}')"
|
585
589
|
|
586
|
-
|
590
|
+
key_tool = nil
|
591
|
+
begin
|
592
|
+
key_tool = Java::SunSecurityTools::KeyTool
|
593
|
+
rescue NameError # Java 8 seems to have removed it completely
|
594
|
+
`keytool #{key_tool_args.join(' ')}` # NOTE: use for all JDK versions
|
595
|
+
else
|
596
|
+
key_tool.main key_tool_args.to_java(:string)
|
597
|
+
end
|
587
598
|
end
|
588
599
|
|
589
600
|
def trap_signals
|
data/lib/trinidad/version.rb
CHANGED
data/lib/trinidad/web_app.rb
CHANGED
@@ -34,9 +34,11 @@ module Trinidad
|
|
34
34
|
use_default ? default_config.key?(key) : false
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
37
|
+
def root_dir; self[:root_dir] end
|
38
|
+
def rackup; self[:rackup] end
|
39
|
+
def host_name; self[:host_name] end
|
40
|
+
def async_supported; self[:async_supported] end
|
41
|
+
def reload_strategy; self[:reload_strategy] end
|
40
42
|
|
41
43
|
alias_method :web_app_dir, :root_dir # is getting deprecated soon
|
42
44
|
def app_root; root_dir; end
|
@@ -46,7 +48,7 @@ module Trinidad
|
|
46
48
|
|
47
49
|
def context_path
|
48
50
|
path = self[:context_path] || self[:path]
|
49
|
-
path ? path.to_s : path
|
51
|
+
path ? path.to_s : path #
|
50
52
|
end
|
51
53
|
|
52
54
|
def context_name
|
@@ -92,7 +94,9 @@ module Trinidad
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def jruby_compat_version
|
95
|
-
fetch_config_value(:jruby_compat_version,
|
97
|
+
compat_version = fetch_config_value(:jruby_compat_version, false)
|
98
|
+
return compat_version unless compat_version.eql? false
|
99
|
+
JRUBY_VERSION < '9.0' ? RUBY_VERSION[0, 3] : nil
|
96
100
|
end
|
97
101
|
|
98
102
|
def environment
|
@@ -173,7 +177,9 @@ module Trinidad
|
|
173
177
|
add_context_param 'jruby.initial.runtimes', jruby_initial_runtimes
|
174
178
|
add_context_param 'jruby.runtime.acquire.timeout', jruby_runtime_acquire_timeout
|
175
179
|
end
|
176
|
-
|
180
|
+
if compat_version = jruby_compat_version
|
181
|
+
add_context_param 'jruby.compat.version', compat_version
|
182
|
+
end
|
177
183
|
add_context_param 'public.root', public_root
|
178
184
|
add_context_param 'jruby.rack.layout_class', layout_class
|
179
185
|
# JRuby::Rack::ErrorApp got a bit smarter so use it, TODO maybe override ?
|
@@ -184,9 +190,8 @@ module Trinidad
|
|
184
190
|
def init_params; context_params; end
|
185
191
|
|
186
192
|
def add_context_param(param_name, param_value)
|
187
|
-
@context_params ||= {}
|
188
193
|
if ! param_value.nil? && ! web_xml_context_param(param_name)
|
189
|
-
@context_params[param_name] = param_value.to_s
|
194
|
+
(@context_params ||= {})[param_name] = param_value.to_s
|
190
195
|
end
|
191
196
|
end
|
192
197
|
|
@@ -422,7 +427,7 @@ module Trinidad
|
|
422
427
|
|
423
428
|
return if key?(:jruby_max_runtimes) || key?(:jruby_min_runtimes)
|
424
429
|
|
425
|
-
if
|
430
|
+
if key?(:threadsafe) && self[:threadsafe] == false
|
426
431
|
max_runtimes = config[:jruby_max_runtimes] = guess_max_runtimes
|
427
432
|
if environment == 'development' || environment == 'test'
|
428
433
|
config[:jruby_min_runtimes] = 1
|
@@ -434,6 +439,7 @@ module Trinidad
|
|
434
439
|
end
|
435
440
|
end
|
436
441
|
|
442
|
+
# @deprecated no longer used
|
437
443
|
def detect_threadsafe?(environment = self.environment); true end
|
438
444
|
|
439
445
|
def guess_max_runtimes; 5 end
|
@@ -590,8 +596,7 @@ module Trinidad
|
|
590
596
|
( default_config && default_config[:context_name] )
|
591
597
|
path = name.to_s == 'default' ? '/' : "/#{name}"
|
592
598
|
end
|
593
|
-
path
|
594
|
-
path.to_s
|
599
|
+
path.to_s[0, 1] != '/' ? "/#{path}" : path.to_s
|
595
600
|
end
|
596
601
|
|
597
602
|
private
|
@@ -672,6 +677,7 @@ module Trinidad
|
|
672
677
|
# NOTE: maybe we can guess these based on connector maxThreads?
|
673
678
|
# def guess_max_runtimes; 5 end
|
674
679
|
|
680
|
+
# @deprecated no longer used
|
675
681
|
def detect_threadsafe?(environment = self.environment)
|
676
682
|
if environment == 'development' || environment == 'test'
|
677
683
|
# NOTE: it's best for development/test to use the same setup as in
|
data/rakelib/tomcat.rake
CHANGED
@@ -3,7 +3,7 @@ require 'tmpdir'
|
|
3
3
|
|
4
4
|
namespace :tomcat do
|
5
5
|
include TrinidadRakeHelpers
|
6
|
-
|
6
|
+
|
7
7
|
TOMCAT_MAVEN_REPO = 'http://repo2.maven.org/maven2/org/apache/tomcat'
|
8
8
|
|
9
9
|
tomcat = "#{TOMCAT_MAVEN_REPO}/embed/tomcat-embed-core/%s/tomcat-embed-core-%s.jar"
|
@@ -11,7 +11,7 @@ namespace :tomcat do
|
|
11
11
|
tomcat_logging = "#{TOMCAT_MAVEN_REPO}/embed/tomcat-embed-logging-log4j/%s/tomcat-embed-logging-log4j-%s.jar"
|
12
12
|
|
13
13
|
dependencies = [ tomcat, tomcat_jasper, tomcat_logging ]
|
14
|
-
|
14
|
+
|
15
15
|
task :fetch, :version do |_, args|
|
16
16
|
tomcat_version = [args[:version]] * 2
|
17
17
|
|
@@ -35,9 +35,9 @@ namespace :tomcat do
|
|
35
35
|
end
|
36
36
|
FileUtils.rm_r temp_dir
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
TOMCAT_CORE_TARGET_DIR = File.expand_path('../../target/tomcat-core', __FILE__)
|
40
|
-
|
40
|
+
|
41
41
|
desc "Updates Tomcat to a given version e.g. `rake tomcat:update[7.0.30]`"
|
42
42
|
task :update, :version do |_, args|
|
43
43
|
Rake::Task['tomcat:fetch'].invoke(version = args[:version])
|
@@ -48,11 +48,11 @@ namespace :tomcat do
|
|
48
48
|
file = File.read(path)
|
49
49
|
file.gsub!(/TOMCAT_VERSION = '(.+)'/, "TOMCAT_VERSION = '#{version}'")
|
50
50
|
File.open(path, 'w') { |io| io.write(file) }
|
51
|
-
|
51
|
+
|
52
52
|
puts "DONE - Tomcat's version has been updated to #{version} succesfully !\n"
|
53
|
-
puts "`export
|
53
|
+
puts "`export TRINIDAD_JARS_VERSION=local && bundle install` to make sure you use the local trinidad_jars gem with Bundler"
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
task :patch do
|
57
57
|
Rake::Task['tomcat-core:jar'].invoke
|
58
58
|
end
|
@@ -61,7 +61,7 @@ namespace :tomcat do
|
|
61
61
|
rm TOMCAT_CORE_JAR if File.exist?(TOMCAT_CORE_JAR)
|
62
62
|
end
|
63
63
|
task :clean => :clear
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
66
|
|
67
67
|
namespace :'tomcat-core' do
|
@@ -77,11 +77,11 @@ namespace :'tomcat-core' do
|
|
77
77
|
end
|
78
78
|
jar TOMCAT_CORE_TARGET_DIR, TOMCAT_CORE_JAR
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
task :clear do
|
82
82
|
rm_r TOMCAT_CORE_TARGET_DIR if File.exist?(TOMCAT_CORE_TARGET_DIR)
|
83
83
|
rm TOMCAT_CORE_JAR if File.exist?(TOMCAT_CORE_JAR)
|
84
84
|
end
|
85
85
|
task :clean => :clear
|
86
|
-
|
86
|
+
|
87
87
|
end
|
data/trinidad.gemspec
CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.rdoc_options = ["--charset=UTF-8"]
|
23
23
|
gem.extra_rdoc_files = %w[README.md LICENSE]
|
24
24
|
|
25
|
-
gem.add_dependency('trinidad_jars', '>= 1.
|
26
|
-
gem.add_dependency('jruby-rack', '
|
25
|
+
gem.add_dependency('trinidad_jars', '>= 1.5', '< 1.7')
|
26
|
+
gem.add_dependency('jruby-rack', '>= 1.1.18', '< 1.3')
|
27
27
|
|
28
28
|
gem.add_development_dependency('rspec', '~> 2.14.1')
|
29
29
|
|
@@ -38,4 +38,4 @@ Gem::Specification.new do |gem|
|
|
38
38
|
|
39
39
|
gem.test_files = gem.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
|
40
40
|
|
41
|
-
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,63 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinidad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.
|
4
|
+
version: 1.5.0.B2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Calavera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: trinidad_jars
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.6.0
|
23
14
|
requirement: !ruby/object:Gem::Requirement
|
24
15
|
requirements:
|
25
|
-
- -
|
16
|
+
- - ">="
|
26
17
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
28
|
-
- - <
|
18
|
+
version: '1.5'
|
19
|
+
- - "<"
|
29
20
|
- !ruby/object:Gem::Version
|
30
|
-
version: 1.
|
21
|
+
version: '1.7'
|
22
|
+
name: trinidad_jars
|
31
23
|
prerelease: false
|
32
24
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: jruby-rack
|
35
25
|
version_requirements: !ruby/object:Gem::Requirement
|
36
26
|
requirements:
|
37
|
-
- -
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- - "<"
|
38
31
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
32
|
+
version: '1.7'
|
33
|
+
- !ruby/object:Gem::Dependency
|
40
34
|
requirement: !ruby/object:Gem::Requirement
|
41
35
|
requirements:
|
42
|
-
- -
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.1.18
|
39
|
+
- - "<"
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.
|
41
|
+
version: '1.3'
|
42
|
+
name: jruby-rack
|
45
43
|
prerelease: false
|
46
44
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec
|
49
45
|
version_requirements: !ruby/object:Gem::Requirement
|
50
46
|
requirements:
|
51
|
-
- -
|
47
|
+
- - ">="
|
52
48
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
49
|
+
version: 1.1.18
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.3'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- - ~>
|
56
|
+
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: 2.14.1
|
59
|
+
name: rspec
|
59
60
|
prerelease: false
|
60
61
|
type: :development
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.14.1
|
61
67
|
description: Trinidad allows you to run Rails or Rack applications within an embedded Apache Tomcat container. Serves your requests with the elegance of a cat !
|
62
68
|
email: calavera@apache.org
|
63
69
|
executables:
|
@@ -99,22 +105,22 @@ licenses:
|
|
99
105
|
metadata: {}
|
100
106
|
post_install_message:
|
101
107
|
rdoc_options:
|
102
|
-
- --charset=UTF-8
|
108
|
+
- "--charset=UTF-8"
|
103
109
|
require_paths:
|
104
110
|
- lib
|
105
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
107
|
-
- -
|
113
|
+
- - ">="
|
108
114
|
- !ruby/object:Gem::Version
|
109
115
|
version: '0'
|
110
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
117
|
requirements:
|
112
|
-
- -
|
118
|
+
- - ">"
|
113
119
|
- !ruby/object:Gem::Version
|
114
120
|
version: 1.3.1
|
115
121
|
requirements: []
|
116
122
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.8
|
118
124
|
signing_key:
|
119
125
|
specification_version: 4
|
120
126
|
summary: Web server for Rails/Rack applications built upon JRuby::Rack and Apache Tomcat
|