trinidad 1.4.4 → 1.4.5.B1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/History.txt +36 -0
- data/README.md +130 -64
- data/Rakefile +6 -3
- data/lib/trinidad.rb +1 -0
- data/lib/trinidad/extensions.rb +16 -16
- data/lib/trinidad/helpers.rb +34 -0
- data/lib/trinidad/lifecycle/base.rb +20 -20
- data/lib/trinidad/lifecycle/host.rb +34 -9
- data/lib/trinidad/lifecycle/host/rolling_reload.rb +31 -9
- data/lib/trinidad/lifecycle/web_app/default.rb +1 -1
- data/lib/trinidad/lifecycle/web_app/shared.rb +15 -8
- data/lib/trinidad/lifecycle/web_app/war.rb +26 -26
- data/lib/trinidad/logging.rb +149 -120
- data/lib/trinidad/server.rb +375 -135
- data/lib/trinidad/version.rb +1 -1
- data/lib/trinidad/web_app.rb +69 -35
- data/rakelib/tomcat.rake +1 -0
- data/trinidad.gemspec +4 -6
- metadata +160 -155
data/Gemfile
CHANGED
data/History.txt
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
== Trinidad 1.4.5.B1 (2013-03-08)
|
2
|
+
|
3
|
+
* Rails 4.0 threadsafe! detection
|
4
|
+
* only configure logging err handler if STDOUT/STDERR changed from JVM default
|
5
|
+
* correctly handle .war file + expanded .war dir (double) deploys
|
6
|
+
* better web app root resolution (relative to host's app base directory)
|
7
|
+
* (always) correctly categorize deployed apps into hosts
|
8
|
+
* support for more fine grained host configuration (including default host)
|
9
|
+
* (once again) working plain-old .war deployment support
|
10
|
+
* make sure context name (once set) is not changed and is kept esp. during
|
11
|
+
rolling reloads even if (slightly) different from configured context_name
|
12
|
+
* fail-safe (zero-downtime) support for rolling reload
|
13
|
+
when a new version of the app fails to boot the old one is kept
|
14
|
+
* depend on latest (>= 1.2.2) jars and jruby-rack >= 1.1.13
|
15
|
+
* review extensions resolution, ignore extension (warn) when it doesn't exist
|
16
|
+
* patch DirectJDKLog to disable log source thus we won't generate a dummy
|
17
|
+
throwable just to obtain the caller stack trace (that ain't really used)
|
18
|
+
* handle immediate log level change with JUL's LogFactory
|
19
|
+
* avoid work_dir deletion on context destory (during rolling reloads)
|
20
|
+
* do not allow public.root == '/' to be used as FS root (#93)
|
21
|
+
|
22
|
+
== Trinidad_jars 1.2.2 (2013-03-08)
|
23
|
+
|
24
|
+
* Tomcat 7.0.37 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
25
|
+
|
26
|
+
== Trinidad_jars 1.2.1 (2013-02-21)
|
27
|
+
|
28
|
+
* Tomcat 7.0.35 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
29
|
+
|
30
|
+
== Trinidad_jars 1.2.0 (2013-01-14)
|
31
|
+
|
32
|
+
* Tomcat 7.0.33 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
33
|
+
* patched JULI's DirectJDKLog to not generate stack traces for every log
|
34
|
+
by default (can be turned back using org.apache.juli.logging.logSource=true)
|
35
|
+
* native (Java) implementations for logging classes, to keep logging AFAP
|
36
|
+
|
1
37
|
== Trinidad 1.4.4 (2012-10-19)
|
2
38
|
|
3
39
|
* make sure setting FileHandler's rotatable to false works (#82)
|
data/README.md
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
# Trinidad
|
2
2
|
|
3
|
-
Trinidad allows you to run Rails or Rack applications within an embedded
|
4
|
-
Apache Tomcat
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
Trinidad allows you to run Rails and/or Rack applications within an embedded
|
4
|
+
Tomcat container. Apache Tomcat (formerly also Jakarta Tomcat) is an open source
|
5
|
+
web server and Servlet container with a long history that dates back to the
|
6
|
+
previous millenia.
|
7
|
+
|
8
|
+
Trinidad's goals with bringing Tomcat into JRuby land are mostly the following :
|
9
|
+
|
10
|
+
- **flexibility** especially in terms of configuration it allows you to tune
|
11
|
+
(almost) everything from a simple *trinidad.yml* (or .rb) configuration file
|
12
|
+
- **portability** there's no vendor lock-in as we use `JRuby::Rack`, thus even
|
13
|
+
if you do some Java integration or use it's Rack Servlet extensions you're
|
14
|
+
still able to migrate to a standalone Tomcat or any other Servlet container
|
15
|
+
- easy Java integration (just in-case you need it, it's there)
|
16
|
+
- **extensions** such as connection pooling (sharing pools between deployed
|
17
|
+
Rails apps) and (threaded) worker adapters for `Resque` and `Delayed::Job`
|
9
18
|
|
10
19
|
## Installation
|
11
20
|
|
@@ -13,42 +22,52 @@ Apache Tomcat container.
|
|
13
22
|
$ jruby -S gem install trinidad
|
14
23
|
```
|
15
24
|
|
25
|
+
Trinidad requires (and supports) JRuby 1.6.8 or later (latest 1.7.x recommended).
|
26
|
+
|
16
27
|
## Quick Start
|
17
28
|
|
18
29
|
```
|
19
|
-
$ cd
|
30
|
+
$ cd a-rails-app
|
20
31
|
$ jruby -S trinidad
|
21
32
|
```
|
22
33
|
|
23
|
-
|
34
|
+
## Setup
|
24
35
|
|
25
|
-
If you use Bundler, you might want to add Trinidad to your *Gemfile
|
36
|
+
If you use Bundler, you might want to add Trinidad to your *Gemfile* :
|
26
37
|
|
27
38
|
```
|
28
39
|
gem 'trinidad', :require => nil
|
29
40
|
```
|
30
41
|
|
31
|
-
|
42
|
+
However this is not absolutely necessary, you might simply `gem install trinidad`
|
43
|
+
and than run `trinidad` - keep in mind a server is not an application dependency.
|
32
44
|
|
33
|
-
|
45
|
+
### Rails
|
46
|
+
|
47
|
+
Trinidad supports the same Rails version as the JRuby-Rack it founds (or is
|
48
|
+
specified/locked in your *Gemfile*), which is **2.3**, **3.x** as well as
|
49
|
+
**4.0** for JRuby-Rack 1.1.x (and the coming 1.2). Merb is not supported.
|
34
50
|
|
35
51
|
```
|
36
|
-
$
|
52
|
+
$ trinidad
|
37
53
|
```
|
38
54
|
|
39
|
-
or
|
55
|
+
or if you prefer to use the Rack handler (e.g. for development) use :
|
40
56
|
|
41
57
|
```
|
42
|
-
$ trinidad
|
58
|
+
$ rails s trinidad
|
43
59
|
```
|
44
60
|
|
45
|
-
|
61
|
+
Please note all configuration options will work using the Rack handler mode, you
|
62
|
+
should usually only use it for development/tests and run `trinidad` on production.
|
63
|
+
|
64
|
+
### Sinatra
|
46
65
|
|
47
66
|
```
|
48
67
|
$ ruby app.rb -s Trinidad
|
49
68
|
```
|
50
69
|
|
51
|
-
or configure your application to always use Trinidad:
|
70
|
+
or configure your application to always use Trinidad :
|
52
71
|
|
53
72
|
```ruby
|
54
73
|
require 'sinatra'
|
@@ -59,30 +78,42 @@ configure do
|
|
59
78
|
end
|
60
79
|
```
|
61
80
|
|
62
|
-
|
81
|
+
### Rackup
|
82
|
+
|
83
|
+
Trinidad auto-detects a plain-old Rack application (if there's a *config.ru*) :
|
84
|
+
|
85
|
+
```
|
86
|
+
$ trinidad
|
87
|
+
```
|
63
88
|
|
64
|
-
You can pass the server name
|
89
|
+
You can as well pass the server name to `rackup` to start the Rack handler :
|
65
90
|
|
66
91
|
```
|
67
92
|
$ rackup -s trinidad
|
68
93
|
```
|
69
94
|
|
70
|
-
Or you can set Trinidad
|
95
|
+
Or you can set Trinidad as the default server in your *config.ru* file :
|
71
96
|
|
72
97
|
```
|
73
98
|
#\ -s trinidad
|
74
99
|
```
|
75
100
|
|
76
|
-
|
77
|
-
|
101
|
+
Trinidad solves the Rack "chicken-egg" problem when booting from a *rackup* file
|
102
|
+
the same way as JRuby-Rack (since it boots all applications), that is :
|
103
|
+
- if a Bundler *Gemfile* is detected, it first does a *bundle/setup* to load rack
|
104
|
+
- otherwise the rack (gem) version might be specified using a magic comment in
|
105
|
+
*config.ru* as `# rack.version: ~>1.4.0` (or the latest installed gem is used)
|
106
|
+
|
107
|
+
**NOTE:** We do recommend to use the plain `trinidad` mode for running apps
|
108
|
+
(in production), since it supports runtime pooling while the "rackup" mode does
|
78
109
|
not, it also provides you with better Java integration possibilities.
|
79
110
|
|
80
|
-
Also note that Trinidad does not mimic JRuby-Rack's
|
81
|
-
for Rails but booting
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
111
|
+
Also note that Trinidad does not mimic JRuby-Rack's (1.1.x) backwards compatible
|
112
|
+
behavior of starting a pool for Rails but booting a thread-safe runtime for
|
113
|
+
plain Rack applications by default. Currently, runtime pooling is the default
|
114
|
+
with Trinidad and stays the same no matter the type of the application.
|
115
|
+
We expect this default to (most likely) change in a future version of Trinidad
|
116
|
+
as thread-safe gets more adopted by (stable) releases of Rails 4.0.
|
86
117
|
|
87
118
|
## Configuration
|
88
119
|
|
@@ -116,8 +147,8 @@ the path by adding the option `default_web_xml` within your configuration file.
|
|
116
147
|
|
117
148
|
### YAML Configuration
|
118
149
|
|
119
|
-
The server can
|
120
|
-
not specified, the server tries to load
|
150
|
+
The server can be configured from a .yml file. By default, if a file is
|
151
|
+
not specified, the server tries to load **config/trinidad.yml**.
|
121
152
|
Within this file you can specify options available on the command line and tune
|
122
153
|
server settings or configure multiple applications to be hosted on the server.
|
123
154
|
|
@@ -138,8 +169,8 @@ $ jruby -S trinidad --config my_trinidad.yml
|
|
138
169
|
### Ruby Configuration
|
139
170
|
|
140
171
|
As an alternative to the *config/trinidad.yml* file, a .rb configuration file
|
141
|
-
might be used to setup Trinidad. It follows the same convention as the
|
142
|
-
configuration - the file
|
172
|
+
might be used to setup Trinidad. It follows the same convention as the YAML
|
173
|
+
configuration - the file **config/trinidad.rb** is loaded by default if exists.
|
143
174
|
|
144
175
|
```ruby
|
145
176
|
Trinidad.configure do |config|
|
@@ -244,7 +275,7 @@ Since version **1.4.0** Trinidad supports 2 reload strategies :
|
|
244
275
|
the **1.3.x** line. If you use this you should account that your JVM memory
|
245
276
|
requirements might increase quite a lot (esp. if you reload under heavy loads)
|
246
277
|
since requests are being served while there's another version of the
|
247
|
-
application being loaded.
|
278
|
+
application being loaded. Since version **1.4.5** rolling reloads support ....
|
248
279
|
|
249
280
|
Configure the reload strategy per web application or globally e.g. :
|
250
281
|
|
@@ -258,40 +289,55 @@ Configure the reload strategy per web application or globally e.g. :
|
|
258
289
|
## Virtual Hosts
|
259
290
|
|
260
291
|
It's possible to use Trinidad with multiple hosts and load the applications under
|
261
|
-
them automatically.
|
262
|
-
|
292
|
+
them automatically. A (virtual) host represents an association of a network name
|
293
|
+
(such as "www.example.com" with the particular server on which Tomcat is running.
|
294
|
+
Please remember that each host must have its applications in a different directory.
|
295
|
+
You can find out more at Tomcat's [documentation][5].
|
263
296
|
|
264
297
|
```ruby
|
265
298
|
Trinidad.configure do |config|
|
266
299
|
config.hosts = {
|
267
|
-
#
|
268
|
-
# (first one is the
|
269
|
-
'
|
270
|
-
'
|
271
|
-
'
|
300
|
+
# applications path (host app base directory) => host names
|
301
|
+
# (first one is the "main" host name, other ones are aliases)
|
302
|
+
'/var/www/local/apps' => ['localhost', '127.0.0.1'],
|
303
|
+
'/home/trinidad/apps' => 'appshost'
|
304
|
+
# NOTE: by default a (default) 'localhost' host is setup
|
272
305
|
}
|
273
306
|
end
|
274
307
|
```
|
275
308
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
309
|
+
Detailed host configuration is also possible using supported [host options][5] :
|
310
|
+
|
311
|
+
```yaml
|
312
|
+
---
|
313
|
+
port: 8080
|
314
|
+
hosts:
|
315
|
+
localhost:
|
316
|
+
app_base: /home/trinidad/apps
|
317
|
+
auto_deploy: false
|
318
|
+
unpackWARs: true
|
319
|
+
```
|
320
|
+
|
321
|
+
If applications are configured via the `web_apps` section, the host for each
|
322
|
+
application can be added with the `host` (or `hosts`) key, if a specified host
|
323
|
+
does not exists (e.g. not configured or not "localhost") it will be created.
|
324
|
+
If several applications belong to the same host, they are expected to reside
|
325
|
+
under the same parent directory e.g. :
|
280
326
|
|
281
327
|
```ruby
|
282
328
|
Trinidad.configure do |config|
|
283
329
|
config.web_apps = {
|
284
330
|
:mock1 => {
|
285
|
-
:
|
286
|
-
:
|
331
|
+
:root_dir => 'rails_apps/mock1',
|
332
|
+
:host => ['rails.virtual.host', 'rails.host']
|
287
333
|
},
|
288
334
|
:mock2 => {
|
289
|
-
:
|
290
|
-
:
|
335
|
+
:root_dir => 'rails_apps/mock2',
|
336
|
+
:host => 'rails.virtual.host'
|
291
337
|
},
|
292
338
|
:mock3 => {
|
293
|
-
:
|
294
|
-
:
|
339
|
+
:root_dir => 'rack_apps/mock3',
|
340
|
+
:host => ['rack.virtual.host', 'rack.host']
|
295
341
|
}
|
296
342
|
}
|
297
343
|
end
|
@@ -299,30 +345,50 @@ end
|
|
299
345
|
|
300
346
|
## Extensions
|
301
347
|
|
302
|
-
Trinidad allows to extend itself with more (not just Tomcat) features
|
303
|
-
|
348
|
+
Trinidad allows to extend itself with more (not just Tomcat) features using
|
349
|
+
extensions, they're essentially components hooked into Tomcat's life-cycle.
|
350
|
+
Here is a list of the available extensions that are "officially supported" :
|
304
351
|
|
305
|
-
* Database Connection Pooling:
|
352
|
+
* Database Connection Pooling :
|
306
353
|
http://github.com/trinidad/trinidad_dbpool_extension
|
307
|
-
* Daemonize Trinidad, based on Akuma:
|
354
|
+
* Daemonize Trinidad, based on Akuma (Unix only) :
|
308
355
|
http://github.com/trinidad/trinidad_daemon_extension
|
309
|
-
* Init Services (for Unix and Windows), based on Commons Daemon:
|
356
|
+
* Init Services (for Unix and Windows), based on Commons Daemon :
|
310
357
|
http://github.com/trinidad/trinidad_init_services
|
311
|
-
*
|
358
|
+
* Scheduler, based on Quartz :
|
359
|
+
http://github.com/trinidad/trinidad_scheduler_extension
|
360
|
+
* Worker, threaded workers (supports Resque, Delayed::Job) :
|
361
|
+
http://github.com/trinidad/trinidad_worker_extension
|
362
|
+
* Logging, enhance Trinidad's logging system :
|
312
363
|
http://github.com/trinidad/trinidad_logging_extension
|
313
|
-
* Application and Server Lifecycle Management:
|
364
|
+
* Application and Server Lifecycle Management :
|
314
365
|
http://github.com/trinidad/trinidad_lifecycle_extension
|
315
|
-
*
|
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):
|
366
|
+
* Valves - components inserted into the request pipeline (e.g. Access Log) :
|
320
367
|
http://github.com/trinidad/trinidad_valve_extension
|
368
|
+
* Trinidad's Management Console and REST API :
|
369
|
+
http://github.com/trinidad/trinidad_sandbox_extension
|
370
|
+
* Enable remote JMX monitoring capabilities for Trinidad :
|
371
|
+
http://github.com/trinidad/trinidad_jmx_remote_extension
|
321
372
|
|
322
|
-
You can find further information on how to write extensions in the wiki
|
323
|
-
|
373
|
+
You can find further information on how to write extensions in the [wiki][4].
|
374
|
+
|
375
|
+
## Support
|
376
|
+
|
377
|
+
* Contact [kares][0] if your team needs JRuby or Trinidad help and support
|
378
|
+
* [Logic Haus][1] provides JRuby related training and development services
|
379
|
+
* [Engine Yard][2] has PaaS cloud support with JRuby and Trinidad
|
380
|
+
* Mailing List: http://groups.google.com/group/rails-trinidad
|
381
|
+
* Bug Tracker: http://github.com/trinidad/trinidad/issues
|
382
|
+
* IRC [Channel on FreeNode][3]: #trinidad (or ask in #jruby)
|
324
383
|
|
325
384
|
## Copyright
|
326
385
|
|
327
|
-
Copyright (c)
|
386
|
+
Copyright (c) 2013 [Team Trinidad](https://github.com/trinidad).
|
328
387
|
See LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.
|
388
|
+
|
389
|
+
[0]: http://github.com/kares
|
390
|
+
[1]: http://logichaus.com/jruby.html
|
391
|
+
[2]: https://www.engineyard.com/blog/2011/leveraging-trinidad-and-jruby-on-appcloud/
|
392
|
+
[3]: http://webchat.freenode.net/?channels=trinidad
|
393
|
+
[4]: http://github.com/trinidad/trinidad/wiki/extensions
|
394
|
+
[5]: http://tomcat.apache.org/tomcat-7.0-doc/config/host.html
|
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
begin
|
2
2
|
require 'bundler/gem_helper'
|
3
|
-
rescue LoadError
|
4
|
-
require
|
5
|
-
|
3
|
+
rescue LoadError => e
|
4
|
+
require('rubygems') && retry
|
5
|
+
raise e
|
6
6
|
end
|
7
7
|
|
8
8
|
task :default => :spec
|
@@ -79,15 +79,18 @@ namespace :'trinidad-rb' do
|
|
79
79
|
|
80
80
|
TRINIDAD_RB_TARGET_DIR = File.expand_path('../target/trinidad-rb', __FILE__)
|
81
81
|
|
82
|
+
desc "Compile trinidad-rb java sources"
|
82
83
|
task :compile do
|
83
84
|
javac "src/trinidad-rb/java", TRINIDAD_RB_TARGET_DIR
|
84
85
|
end
|
85
86
|
|
87
|
+
desc "Package trinidad-rb.jar"
|
86
88
|
task :jar => :compile do
|
87
89
|
rm TRINIDAD_RB_JAR if File.exist?(TRINIDAD_RB_JAR)
|
88
90
|
jar TRINIDAD_RB_TARGET_DIR, TRINIDAD_RB_JAR
|
89
91
|
end
|
90
92
|
|
93
|
+
desc "Remove trinidad-rb.jar"
|
91
94
|
task :clear do
|
92
95
|
rm_r TRINIDAD_RB_TARGET_DIR if File.exist?(TRINIDAD_RB_TARGET_DIR)
|
93
96
|
rm TRINIDAD_RB_JAR if File.exist?(TRINIDAD_RB_JAR)
|
data/lib/trinidad.rb
CHANGED
data/lib/trinidad/extensions.rb
CHANGED
@@ -37,9 +37,18 @@ module Trinidad
|
|
37
37
|
protected
|
38
38
|
|
39
39
|
def self.extension(name, type, options)
|
40
|
-
class_name =
|
41
|
-
|
42
|
-
|
40
|
+
class_name = Helpers.camelize(name) << type; clazz = nil
|
41
|
+
if ( const_defined?(class_name) rescue nil )
|
42
|
+
clazz = const_get(class_name)
|
43
|
+
else
|
44
|
+
begin
|
45
|
+
load_extension(name)
|
46
|
+
rescue LoadError => e
|
47
|
+
Helpers.warn("Failed to load the #{name.inspect} extension (#{e.message}) ")
|
48
|
+
else
|
49
|
+
clazz = ( const_get(class_name) if const_defined?(class_name) ) rescue nil
|
50
|
+
end
|
51
|
+
end
|
43
52
|
clazz.new(options) if clazz # MyExtension.new(options)
|
44
53
|
end
|
45
54
|
|
@@ -54,17 +63,13 @@ module Trinidad
|
|
54
63
|
end
|
55
64
|
|
56
65
|
def self.camelize(string)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def self.camelize(string)
|
61
|
-
string = string.sub(/^[a-z\d]*/) { $&.capitalize }
|
62
|
-
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
|
63
|
-
string.gsub!('/', '::')
|
64
|
-
string
|
66
|
+
Helpers.deprecate("Trinidad::Extensions.camelize use the camelize helper " <<
|
67
|
+
"available in your Extension")
|
68
|
+
Helpers.camelize(string)
|
65
69
|
end
|
66
70
|
|
67
71
|
class Extension
|
72
|
+
include Helpers; extend Helpers
|
68
73
|
|
69
74
|
attr_reader :options
|
70
75
|
|
@@ -78,11 +83,6 @@ module Trinidad
|
|
78
83
|
def symbolize(options, deep = false)
|
79
84
|
Trinidad::Configuration.symbolize_options(options, deep)
|
80
85
|
end
|
81
|
-
|
82
|
-
# String#camelize
|
83
|
-
def camelize(string)
|
84
|
-
Trinidad::Extensions.send :camelize, string
|
85
|
-
end
|
86
86
|
|
87
87
|
end
|
88
88
|
|