trinidad 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +15 -0
- data/README.rdoc +13 -5
- data/bin/trinidad +0 -3
- data/lib/trinidad.rb +3 -6
- data/lib/trinidad/command_line_parser.rb +8 -13
- data/lib/trinidad/lifecycle/lifecycle_listener_base.rb +8 -0
- data/lib/trinidad/lifecycle/lifecycle_listener_host.rb +49 -0
- data/lib/trinidad/server.rb +20 -6
- data/lib/trinidad/war_web_app.rb +4 -0
- data/lib/trinidad/web_app.rb +13 -0
- metadata +14 -28
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== Trinidad 1.1.0 (2011-03-18)
|
2
|
+
|
3
|
+
* Hot deployment integrated in the core gem
|
4
|
+
* Load config/trinidad.yml by default without the `-f` option if it exists
|
5
|
+
* Load config.ru for applications under the `apps_base` directory when the option is enabled
|
6
|
+
* Share the JRuby runtime with JRuby-Rack
|
7
|
+
|
8
|
+
== Trinidad_jars 1.0.1 (2011-03-17)
|
9
|
+
|
10
|
+
* Upgrade to Tomcat 7.0.11
|
11
|
+
|
12
|
+
== Trinidad_jars 1.0.0 (2011-01-18)
|
13
|
+
|
14
|
+
* Upgrade to Tomcat 7.0.6, first stable release of the Tomcat 7 branch.
|
15
|
+
|
1
16
|
== 1.0.5 (2011-01-13)
|
2
17
|
|
3
18
|
* Fix trailing spaces on arguments. Thank you Windows.
|
data/README.rdoc
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
|
4
4
|
|
5
|
-
Mail list: http://groups.google.com/group/rails-trinidad
|
6
|
-
Bug tracker: http://github.com/calavera/trinidad/issues
|
5
|
+
* Mail list: http://groups.google.com/group/rails-trinidad
|
6
|
+
* Bug tracker: http://github.com/calavera/trinidad/issues
|
7
|
+
* Irc channel on Freenode: #trinidad
|
7
8
|
|
8
9
|
== INSTALL:
|
9
10
|
|
@@ -51,21 +52,28 @@ Trinidad allows you to configure some parameters when the server is started from
|
|
51
52
|
* -g, --log LEVEL => set the log level, default INFO.
|
52
53
|
* --apps APPS_BASE_DIRECTORY => set the applications base directory.
|
53
54
|
|
54
|
-
The server can also be configured from a yaml file.
|
55
|
+
The server can also be configured from a yaml file. By default, if a file is not especified, the server tries to load the file <em>config/trinidad.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
|
55
56
|
|
56
|
-
jruby -S trinidad -f
|
57
57
|
jruby -S trinidad --config my_custom_configuration.yml
|
58
58
|
|
59
59
|
You can also specify a default web.xml to config your web application. By default the server tries to load the file <em>config/web.xml</em> but you can modify this path adding the option <em>default_web_xml</em> within your configuration file.
|
60
60
|
|
61
61
|
Other advanced options can be found in the wiki: http://wiki.github.com/calavera/trinidad/advanced-configuration
|
62
62
|
|
63
|
+
== HOT DEPLOYMENT:
|
64
|
+
|
65
|
+
Although the early versions of Trinidad used an extension to let deploy applications monitorizing a file, since Trinidad 1.1.0 this feature is
|
66
|
+
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
|
67
|
+
modified with the option `:monitor`.
|
68
|
+
|
63
69
|
== EXTENSIONS:
|
64
70
|
|
65
71
|
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:
|
66
72
|
|
67
73
|
* Database connection pooling: http://github.com/calavera/trinidad-dbpool
|
68
|
-
*
|
74
|
+
* Daemons:
|
75
|
+
** Daemon based on Akuma (ala GF gem): http://github.com/calavera/trinidad_daemon_extension
|
76
|
+
** Daemon based on Apache Commons Daemon (supports Unix and Windows systems): http://github.com/calavera/trinidad_daemon
|
69
77
|
* Hot deploy, do hot deploys monitorizing a temporal file, ala Passenger: http://github.com/calavera/trinidad_hotdeploy_extension
|
70
78
|
* Sandbox, management console and REST api: http://github.com/calavera/trinidad_sandbox_extension
|
71
79
|
* Logging, enhance the Trinidad's logging system: http://github.com/calavera/trinidad_logging_extension
|
data/bin/trinidad
CHANGED
data/lib/trinidad.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
-
|
4
|
-
require "java"
|
1
|
+
require 'java'
|
5
2
|
require 'rubygems'
|
6
3
|
|
7
4
|
require 'jruby-rack'
|
8
|
-
require JRubyJars.jruby_rack_jar_path
|
9
5
|
|
10
6
|
gem 'trinidad_jars'
|
11
7
|
|
@@ -15,6 +11,7 @@ require 'trinidad/extensions'
|
|
15
11
|
require 'trinidad/command_line_parser'
|
16
12
|
require 'trinidad/jars'
|
17
13
|
require 'trinidad/server'
|
14
|
+
require 'trinidad/lifecycle/lifecycle_listener_host'
|
18
15
|
require 'trinidad/lifecycle/lifecycle_listener_base'
|
19
16
|
require 'trinidad/lifecycle/lifecycle_listener_default'
|
20
17
|
require 'trinidad/lifecycle/lifecycle_listener_war'
|
@@ -24,5 +21,5 @@ require 'trinidad/rackup_web_app'
|
|
24
21
|
require 'trinidad/war_web_app'
|
25
22
|
|
26
23
|
module Trinidad
|
27
|
-
VERSION = '1.0
|
24
|
+
VERSION = '1.1.0'
|
28
25
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Trinidad
|
2
2
|
require 'optparse'
|
3
|
-
require 'yaml'
|
4
3
|
|
5
4
|
class CommandLineParser
|
6
5
|
attr_reader :default_options
|
@@ -17,7 +16,8 @@ module Trinidad
|
|
17
16
|
:libs_dir => 'lib',
|
18
17
|
:classes_dir => 'classes',
|
19
18
|
:ssl_port => 8443,
|
20
|
-
:ajp_port => 8009
|
19
|
+
:ajp_port => 8009,
|
20
|
+
:config => 'config/trinidad.yml'
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
@@ -30,10 +30,13 @@ module Trinidad
|
|
30
30
|
end
|
31
31
|
|
32
32
|
if default_options.has_key?(:config)
|
33
|
+
require 'yaml'
|
33
34
|
default_options[:config] = File.expand_path(default_options[:config], default_options[:web_app_dir] || Dir.pwd)
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
if File.exist?(default_options[:config])
|
37
|
+
config_options = YAML.load_file(default_options[:config])
|
38
|
+
default_options.deep_merge!(config_options.symbolize!)
|
39
|
+
end
|
37
40
|
end
|
38
41
|
|
39
42
|
default_options
|
@@ -88,15 +91,7 @@ module Trinidad
|
|
88
91
|
|
89
92
|
opts.on('-f', '--config [CONFIG_FILE]', 'Configuration file',
|
90
93
|
"default: #{default_options[:config]}") do |file|
|
91
|
-
default_options[:config] =
|
92
|
-
|
93
|
-
if file
|
94
|
-
default_options[:config] = file
|
95
|
-
elsif File.exist?('config/tomcat.yml') && !File.exist?(default_options[:config])
|
96
|
-
puts "[WARNING] Default configuration file name has been moved to trinidad.yml, tomcat.yml will not be supported in future versions."
|
97
|
-
puts "\tYou still can use tomcat.yml passing it as the file name to this option: -f config/tomcat.yml"
|
98
|
-
default_options[:config] = 'config/tomcat.yml'
|
99
|
-
end
|
94
|
+
default_options[:config] = file unless file.nil?
|
100
95
|
end
|
101
96
|
|
102
97
|
opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file',
|
@@ -2,6 +2,7 @@ module Trinidad
|
|
2
2
|
module Lifecycle
|
3
3
|
class Base
|
4
4
|
include Trinidad::Tomcat::LifecycleListener
|
5
|
+
attr_reader :webapp
|
5
6
|
|
6
7
|
def initialize(webapp)
|
7
8
|
@webapp = webapp
|
@@ -17,9 +18,16 @@ module Trinidad
|
|
17
18
|
|
18
19
|
def configure_defaults(context)
|
19
20
|
remove_defaults(context)
|
21
|
+
configure_context_runtime(context)
|
20
22
|
configure_logging
|
21
23
|
end
|
22
24
|
|
25
|
+
def configure_context_runtime(context)
|
26
|
+
if @webapp.solo? && @webapp.threadsafe?
|
27
|
+
context.servlet_context.set_attribute('jruby.runtime', JRuby.runtime)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
23
31
|
def remove_defaults(context)
|
24
32
|
context.remove_welcome_file('index.jsp')
|
25
33
|
context.remove_welcome_file('index.htm')
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Trinidad
|
2
|
+
module Lifecycle
|
3
|
+
class Host
|
4
|
+
include Trinidad::Tomcat::LifecycleListener
|
5
|
+
|
6
|
+
attr_reader :contexts
|
7
|
+
|
8
|
+
def initialize(*contexts)
|
9
|
+
@contexts = contexts
|
10
|
+
end
|
11
|
+
|
12
|
+
def lifecycleEvent(event)
|
13
|
+
host = event.lifecycle
|
14
|
+
case event.type
|
15
|
+
when Trinidad::Tomcat::Lifecycle::BEFORE_START_EVENT
|
16
|
+
init_monitors
|
17
|
+
when Trinidad::Tomcat::Lifecycle::PERIODIC_EVENT
|
18
|
+
check_monitors
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def init_monitors
|
23
|
+
@contexts.each do |c|
|
24
|
+
monitor = c[:monitor]
|
25
|
+
opts = File.exist?(monitor) ? 'r' : 'w+'
|
26
|
+
|
27
|
+
unless File.exist?(dir = File.dirname(monitor))
|
28
|
+
Dir.mkdir dir
|
29
|
+
end
|
30
|
+
file = File.new(monitor, opts)
|
31
|
+
c[:mtime] = file.mtime
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_monitors
|
36
|
+
@contexts.each do |c|
|
37
|
+
# double check monitor, capistrano removes it temporarily
|
38
|
+
sleep(0.5) unless File.exist?(c[:monitor])
|
39
|
+
next unless File.exist?(c[:monitor])
|
40
|
+
|
41
|
+
if (mtime = File.mtime(c[:monitor])) > c[:mtime]
|
42
|
+
c[:mtime] = mtime
|
43
|
+
c[:context].reload
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/trinidad/server.rb
CHANGED
@@ -21,7 +21,8 @@ module Trinidad
|
|
21
21
|
def initialize(config = {})
|
22
22
|
load_config(config)
|
23
23
|
load_tomcat_server
|
24
|
-
create_web_apps
|
24
|
+
apps = create_web_apps
|
25
|
+
load_host_monitor(apps)
|
25
26
|
end
|
26
27
|
|
27
28
|
def load_config(config)
|
@@ -46,13 +47,20 @@ module Trinidad
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def create_web_apps
|
49
|
-
|
50
|
-
|
50
|
+
apps = []
|
51
|
+
apps << create_from_web_apps
|
52
|
+
apps << create_from_apps_base
|
53
|
+
|
54
|
+
apps.flatten.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_host_monitor(apps)
|
58
|
+
@tomcat.host.add_lifecycle_listener(Trinidad::Lifecycle::Host.new(*apps))
|
51
59
|
end
|
52
60
|
|
53
61
|
def create_from_web_apps
|
54
62
|
if @config[:web_apps]
|
55
|
-
@config[:web_apps].
|
63
|
+
@config[:web_apps].map do |name, app_config|
|
56
64
|
app_config[:context_path] ||= (name.to_s == 'default' ? '' : "/#{name.to_s}")
|
57
65
|
app_config[:web_app_dir] ||= Dir.pwd
|
58
66
|
|
@@ -68,13 +76,16 @@ module Trinidad
|
|
68
76
|
|
69
77
|
apps_path.reject! {|path| apps_path.include?(path + '.war') }
|
70
78
|
|
71
|
-
apps_path.
|
79
|
+
apps_path.map do |path|
|
72
80
|
if (File.directory?(path) || path =~ /\.war$/)
|
73
81
|
name = File.basename(path)
|
74
82
|
app_config = {
|
75
83
|
:context_path => (name == 'default' ? '' : "/#{name.to_s}"),
|
76
84
|
:web_app_dir => File.expand_path(path)
|
77
85
|
}
|
86
|
+
if File.directory?(path) && File.exist?(File.expand_path('config.ru', path))
|
87
|
+
app_config[:rackup] = 'config.ru'
|
88
|
+
end
|
78
89
|
|
79
90
|
create_web_app(app_config)
|
80
91
|
end
|
@@ -91,6 +102,8 @@ module Trinidad
|
|
91
102
|
|
92
103
|
lifecycle = web_app.war? ? Lifecycle::War.new(web_app) : Lifecycle::Default.new(web_app)
|
93
104
|
app_context.add_lifecycle_listener(lifecycle)
|
105
|
+
|
106
|
+
{:context => app_context, :monitor => web_app.monitor}
|
94
107
|
end
|
95
108
|
|
96
109
|
def add_service_connector(options, protocol = nil)
|
@@ -192,7 +205,8 @@ module Trinidad
|
|
192
205
|
default_app = {
|
193
206
|
:context_path => config[:context_path],
|
194
207
|
:web_app_dir => config[:web_app_dir] || Dir.pwd,
|
195
|
-
:log => config[:log]
|
208
|
+
:log => config[:log],
|
209
|
+
:solo => true
|
196
210
|
}
|
197
211
|
default_app[:rackup] = config[:rackup] if (config.has_key?(:rackup))
|
198
212
|
|
data/lib/trinidad/war_web_app.rb
CHANGED
data/lib/trinidad/web_app.rb
CHANGED
@@ -83,6 +83,19 @@ module Trinidad
|
|
83
83
|
def work_dir; web_app_dir; end
|
84
84
|
def environment; @app_config[:environment] || @config[:environment] || 'development'; end
|
85
85
|
|
86
|
+
def solo?
|
87
|
+
!self.is_a?(WarWebApp) && @app_config[:solo]
|
88
|
+
end
|
89
|
+
|
90
|
+
def threadsafe?
|
91
|
+
jruby_min_runtimes.to_i == 1 && jruby_max_runtimes.to_i == 1
|
92
|
+
end
|
93
|
+
|
94
|
+
def monitor
|
95
|
+
m_file = @app_config[:monitor] || @config[:monitor] || 'tmp/restart.txt'
|
96
|
+
File.expand_path(m_file, work_dir)
|
97
|
+
end
|
98
|
+
|
86
99
|
protected
|
87
100
|
def add_parameter_unless_exist(param_name, param_value)
|
88
101
|
@params[param_name] = param_value unless web_context_param(param_name)
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinidad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
version: 1.0.5
|
4
|
+
prerelease:
|
5
|
+
version: 1.1.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- David Calavera
|
@@ -14,46 +10,39 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-18 00:00:00 -07:00
|
18
14
|
default_executable: trinidad
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
17
|
name: trinidad_jars
|
22
18
|
prerelease: false
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
24
21
|
requirements:
|
25
22
|
- - ">="
|
26
23
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
version: 0.3.0
|
24
|
+
version: 1.0.0
|
32
25
|
type: :runtime
|
33
26
|
version_requirements: *id001
|
34
27
|
- !ruby/object:Gem::Dependency
|
35
28
|
name: jruby-rack
|
36
29
|
prerelease: false
|
37
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 1
|
43
|
-
- 0
|
44
|
-
- 2
|
45
|
-
version: 1.0.2
|
35
|
+
version: 1.0.6
|
46
36
|
type: :runtime
|
47
37
|
version_requirements: *id002
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
39
|
name: rspec
|
50
40
|
prerelease: false
|
51
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
52
43
|
requirements:
|
53
44
|
- - ">="
|
54
45
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
46
|
version: "0"
|
58
47
|
type: :development
|
59
48
|
version_requirements: *id003
|
@@ -61,11 +50,10 @@ dependencies:
|
|
61
50
|
name: mocha
|
62
51
|
prerelease: false
|
63
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
64
54
|
requirements:
|
65
55
|
- - ">="
|
66
56
|
- !ruby/object:Gem::Version
|
67
|
-
segments:
|
68
|
-
- 0
|
69
57
|
version: "0"
|
70
58
|
type: :development
|
71
59
|
version_requirements: *id004
|
@@ -73,11 +61,10 @@ dependencies:
|
|
73
61
|
name: fakefs
|
74
62
|
prerelease: false
|
75
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
76
65
|
requirements:
|
77
66
|
- - ">="
|
78
67
|
- !ruby/object:Gem::Version
|
79
|
-
segments:
|
80
|
-
- 0
|
81
68
|
version: "0"
|
82
69
|
type: :development
|
83
70
|
version_requirements: *id005
|
@@ -106,6 +93,7 @@ files:
|
|
106
93
|
- lib/trinidad/web_app.rb
|
107
94
|
- lib/trinidad/lifecycle/lifecycle_listener_base.rb
|
108
95
|
- lib/trinidad/lifecycle/lifecycle_listener_default.rb
|
96
|
+
- lib/trinidad/lifecycle/lifecycle_listener_host.rb
|
109
97
|
- lib/trinidad/lifecycle/lifecycle_listener_war.rb
|
110
98
|
has_rdoc: true
|
111
99
|
homepage: http://github.com/calavera/trinidad
|
@@ -117,23 +105,21 @@ rdoc_options:
|
|
117
105
|
require_paths:
|
118
106
|
- lib
|
119
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
120
109
|
requirements:
|
121
110
|
- - ">="
|
122
111
|
- !ruby/object:Gem::Version
|
123
|
-
segments:
|
124
|
-
- 0
|
125
112
|
version: "0"
|
126
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
127
115
|
requirements:
|
128
116
|
- - ">="
|
129
117
|
- !ruby/object:Gem::Version
|
130
|
-
segments:
|
131
|
-
- 0
|
132
118
|
version: "0"
|
133
119
|
requirements: []
|
134
120
|
|
135
121
|
rubyforge_project: trinidad
|
136
|
-
rubygems_version: 1.
|
122
|
+
rubygems_version: 1.5.1
|
137
123
|
signing_key:
|
138
124
|
specification_version: 2
|
139
125
|
summary: Simple library to run rails applications into an embedded Tomcat
|