jetpack 0.0.3
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/.gitignore +4 -0
- data/.wrong +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +23 -0
- data/README.markdown +35 -0
- data/Rakefile +16 -0
- data/bin/preflight +175 -0
- data/bin_files/.rake_runner.erb +36 -0
- data/bin_files/rake.erb +12 -0
- data/bin_files/ruby.erb +4 -0
- data/gems/bundler-1.0.18.gem +0 -0
- data/gems/bundler-1.1.rc.gem +0 -0
- data/gems/jruby-openssl-0.7.4.gem +0 -0
- data/install_gem.sh +5 -0
- data/jetpack.gemspec +19 -0
- data/jetty_files/etc/fake.p12 +0 -0
- data/jetty_files/etc/jetty.xml.erb +113 -0
- data/jetty_files/jetty-init.erb +702 -0
- data/jetty_files/run/.gitkeep +0 -0
- data/jetty_files/start.ini +69 -0
- data/jetty_files/webapps/.gitkeep +0 -0
- data/lib/preflight/settings.rb +48 -0
- data/script/ci +57 -0
- data/spec/basics_spec.rb +84 -0
- data/spec/bundler_spec.rb +120 -0
- data/spec/ruby_19_spec.rb +34 -0
- data/spec/sample_projects/has_gems_via_bundler/Gemfile +4 -0
- data/spec/sample_projects/has_gems_via_bundler/Gemfile.lock +13 -0
- data/spec/sample_projects/has_gems_via_bundler/Rakefile +18 -0
- data/spec/sample_projects/has_gems_via_bundler/config/preflight.yml +1 -0
- data/spec/sample_projects/has_gems_via_bundler/true} +0 -0
- data/spec/sample_projects/has_gems_via_bundler_19/Gemfile +8 -0
- data/spec/sample_projects/has_gems_via_bundler_19/Gemfile.lock +13 -0
- data/spec/sample_projects/has_gems_via_bundler_19/Rakefile +18 -0
- data/spec/sample_projects/has_gems_via_bundler_19/config/preflight.yml +2 -0
- data/spec/sample_projects/has_gems_via_bundler_bad_gemfile_lock/Gemfile +4 -0
- data/spec/sample_projects/has_gems_via_bundler_bad_gemfile_lock/Rakefile +18 -0
- data/spec/sample_projects/has_gems_via_bundler_bad_gemfile_lock/config/preflight.yml +1 -0
- data/spec/sample_projects/no_dependencies/Rakefile +30 -0
- data/spec/sample_projects/no_dependencies/config/preflight.yml +1 -0
- data/spec/sample_projects/webapp/Gemfile +3 -0
- data/spec/sample_projects/webapp/Gemfile.lock +88 -0
- data/spec/sample_projects/webapp/app/controllers/application_controller.rb +5 -0
- data/spec/sample_projects/webapp/config.ru +4 -0
- data/spec/sample_projects/webapp/config/application.rb +46 -0
- data/spec/sample_projects/webapp/config/boot.rb +6 -0
- data/spec/sample_projects/webapp/config/environment.rb +5 -0
- data/spec/sample_projects/webapp/config/environments/development.rb +25 -0
- data/spec/sample_projects/webapp/config/environments/test.rb +35 -0
- data/spec/sample_projects/webapp/config/initializers/secret_token.rb +7 -0
- data/spec/sample_projects/webapp/config/preflight.yml +6 -0
- data/spec/sample_projects/webapp/config/preflight_files/vendor/jetty/etc/custom-project-specific-jetty.xml +5 -0
- data/spec/sample_projects/webapp/config/preflight_files/vendor/jetty/etc/template-from-project-jetty.xml.erb +9 -0
- data/spec/sample_projects/webapp/config/routes.rb +60 -0
- data/spec/sample_projects/webapp/public/index.html +239 -0
- data/spec/sample_projects/webapp/script/rails +6 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/suite.rb +1 -0
- data/spec/web_spec.rb +67 -0
- data/web_inf_files/web.xml.erb +47 -0
- metadata +175 -0
data/.gitignore
ADDED
data/.wrong
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
open4 (1.1.0)
|
6
|
+
rake (0.9.2.2)
|
7
|
+
rspec (2.6.0)
|
8
|
+
rspec-core (~> 2.6.0)
|
9
|
+
rspec-expectations (~> 2.6.0)
|
10
|
+
rspec-mocks (~> 2.6.0)
|
11
|
+
rspec-core (2.6.4)
|
12
|
+
rspec-expectations (2.6.0)
|
13
|
+
diff-lcs (~> 1.1.2)
|
14
|
+
rspec-mocks (2.6.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
java
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
open4
|
22
|
+
rake
|
23
|
+
rspec
|
data/README.markdown
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Preflight
|
2
|
+
|
3
|
+
Preflight prepares your (j)ruby project for jvm deployment.
|
4
|
+
|
5
|
+
Preflight, as much as possible, uses standard ruby-world tools to prepare the app for deployment, and then presents the ruby app to jetty as a Java EE web application.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
Deploys need to be performed using MRI. Here is a sample section of a project Gemfile:
|
10
|
+
|
11
|
+
platforms :ruby_19 do
|
12
|
+
gem 'preflight'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
Create `config/preflight.yml` in your project:
|
17
|
+
|
18
|
+
jruby: "http://jruby.org.s3.amazonaws.com/downloads/1.6.5.1/jruby-complete-1.6.5.1.jar"
|
19
|
+
jetty: "http://dist.codehaus.org/jetty/jetty-hightide-7.4.5/jetty-hightide-7.4.5.v20110725.zip"
|
20
|
+
jruby-rack: "http://repository.codehaus.org/org/jruby/rack/jruby-rack/1.0.10/jruby-rack-1.0.10.jar"
|
21
|
+
app_user: "myapp"
|
22
|
+
app_root: "/usr/local/myapp/myapp"
|
23
|
+
|
24
|
+
Run preflight:
|
25
|
+
|
26
|
+
gem install preflight
|
27
|
+
|
28
|
+
preflight [your project directory]
|
29
|
+
|
30
|
+
Of note, you'll now have:
|
31
|
+
|
32
|
+
* a `bin` directory, with scripts that run ruby and rake, using jruby and with the gems defined in your project.
|
33
|
+
* a `vendor/jetty directory`, containing everything necessary to run your app using jetty.
|
34
|
+
* You can try your app out by cd'ing into `vendor/jetty` and running `RAILS_ENV=development java -jar start.jar`
|
35
|
+
* `vendor/jetty/jetty-init` is an init script that starts your project. You should symlink `/etc/init.d/[appuser]-jetty` to this file, and then point monit at `/etc/init.d/[appuser]-jetty`
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
namespace :spec do
|
5
|
+
desc "Download required support files for running specs."
|
6
|
+
task :setup do
|
7
|
+
def local_mirror(url)
|
8
|
+
local_path = "spec/local_mirror/" + File.basename(url)
|
9
|
+
`curl #{url} > #{local_path}` unless File.exists?(local_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
local_mirror "http://jruby.org.s3.amazonaws.com/downloads/1.6.4/jruby-complete-1.6.4.jar"
|
13
|
+
local_mirror "http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-hightide/7.4.5.v20110725/jetty-hightide-7.4.5.v20110725.zip"
|
14
|
+
local_mirror "http://repo1.maven.org/maven2/org/jruby/rack/jruby-rack/1.0.10/jruby-rack-1.0.10.jar"
|
15
|
+
end
|
16
|
+
end
|
data/bin/preflight
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
#think: bash-like ruby
|
4
|
+
|
5
|
+
require "yaml"
|
6
|
+
require "erb"
|
7
|
+
require "fileutils"
|
8
|
+
require "etc"
|
9
|
+
|
10
|
+
local_lib_dir = File.join(File.dirname(__FILE__), "../lib")
|
11
|
+
$LOAD_PATH << local_lib_dir if File.directory?(local_lib_dir)
|
12
|
+
|
13
|
+
#Env vars like RUBYOPT get passed on to jruby.
|
14
|
+
#Cleanse the environment of these vars so that jruby is not affected.
|
15
|
+
ENV.delete_if{|k,v|k =~ /(^RUBY|^BUNDLE)/}
|
16
|
+
|
17
|
+
require "preflight/settings"
|
18
|
+
|
19
|
+
include FileUtils
|
20
|
+
|
21
|
+
def halt(message)
|
22
|
+
$stderr.puts message
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def x!(cmd)
|
27
|
+
puts cmd if ENV['VERBOSE']
|
28
|
+
system(cmd) || halt("'#{cmd}' failed.")
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
halt("usage: preflight <project_path>") unless ARGV.length==1 && File.directory?(ARGV[0])
|
33
|
+
|
34
|
+
@path_to_project = ARGV.shift
|
35
|
+
@created = []
|
36
|
+
|
37
|
+
@settings = Preflight::Settings.load_from_project(@path_to_project)
|
38
|
+
|
39
|
+
puts @settings.inspect
|
40
|
+
|
41
|
+
unless @settings.jruby?
|
42
|
+
halt(%{Your config/preflight.yml must at least contain a pointer to the desired jruby-complete jar.
|
43
|
+
Ex:
|
44
|
+
|
45
|
+
jruby: http://jruby.org.s3.amazonaws.com/downloads/1.6.4/jruby-complete-1.6.4.jar
|
46
|
+
jetty: http://dist.codehaus.org/jetty/jetty-hightide-7.4.5/jetty-hightide-7.4.5.v20110725.zip
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
script_start_time = Time.now
|
51
|
+
|
52
|
+
@jruby_jar_file = "vendor/jruby.jar"
|
53
|
+
@preflight_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
54
|
+
|
55
|
+
@gem_home = "file:" + File.expand_path(File.join(@settings.app_root, @jruby_jar_file)) + "!/META-INF/jruby.home/lib/ruby/gems/1.8"
|
56
|
+
@gem_path = @gem_home + ":vendor/bundler_gem"
|
57
|
+
|
58
|
+
@java_dash_jar = "PATH=$PATH:$(dirname $0) GEM_HOME=\"#{@gem_home}\" GEM_PATH=\"#{@gem_path}\" exec java #{@settings.java_options} -jar"
|
59
|
+
@jruby_opts = @settings.ruby_version.to_s == '1.9' ? '--1.9' : ''
|
60
|
+
|
61
|
+
def jruby!(cmd)
|
62
|
+
x! "cd #{@path_to_project} && #{@java_dash_jar} #{@jruby_jar_file} #{@jruby_opts} #{cmd}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def download(url, local_file)
|
66
|
+
x! "curl --silent --show-error -o #{local_file} #{url}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def unzip(file, directory, pattern="")
|
70
|
+
x! "unzip -qq #{file} #{pattern} -d #{directory}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def install_bundler_gem
|
74
|
+
unless File.exists?("#{@path_to_project}/vendor/bundler_gem")
|
75
|
+
jruby! " -S gem install #{@preflight_dir}/gems/bundler-1.1.rc.gem -i vendor/bundler_gem --no-rdoc --no-ri"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def regenerate_gemfile_lock_if_platform_java_is_not_found
|
80
|
+
gemfile_lock_lines = File.read(File.join(@path_to_project, "Gemfile.lock")).split("\n")
|
81
|
+
platforms_start = gemfile_lock_lines.find_index{|line|line == "PLATFORMS"} + 1
|
82
|
+
platforms_count = gemfile_lock_lines.slice(platforms_start..-1).find_index{|line|line == ""} - 1
|
83
|
+
platforms = gemfile_lock_lines.slice(platforms_start..(platforms_start+platforms_count)).map{|platform_str|platform_str.strip}
|
84
|
+
unless platforms.include?("java")
|
85
|
+
$stderr.puts %{
|
86
|
+
WARNING: Your Gemfile.lock does not contain PLATFORM java.
|
87
|
+
Automtically regenerating and overwriting Gemfile.lock using jruby
|
88
|
+
- because otherwise, jruby-specific gems would not be installed by bundler.
|
89
|
+
To make this message go away, you must re-generate your Gemfile.lock using jruby.
|
90
|
+
}
|
91
|
+
jruby! " -e 'require \"rubygems\"; require \"bundler\"; Bundler.definition.lock(Bundler.default_lockfile)'"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def bundle_install
|
96
|
+
install_bundler_gem
|
97
|
+
regenerate_gemfile_lock_if_platform_java_is_not_found
|
98
|
+
#Do the equivalent of 'bundle' in code so we know exactly which bundler we're using.
|
99
|
+
jruby! " -e 'require \"rubygems\"; require \"bundler\"; require \"bundler/cli\"; cli=Bundler::CLI.new; cli.options={:deployment=>true}; cli.install'"
|
100
|
+
end
|
101
|
+
|
102
|
+
def install_jetty(vendor_dir)
|
103
|
+
jetty_dir = File.join(vendor_dir, "jetty")
|
104
|
+
Dir["#{vendor_dir}/jett*"].to_a.each{|f|rm_rf(f)}
|
105
|
+
download @settings.jetty, File.join(vendor_dir, "jetty.zip")
|
106
|
+
unzip File.join(vendor_dir, "jetty.zip"), vendor_dir
|
107
|
+
rm File.join(vendor_dir, "jetty.zip")
|
108
|
+
mv Dir["#{vendor_dir}/jetty*"].to_a.first, jetty_dir
|
109
|
+
rm_rf "#{jetty_dir}/webapps"
|
110
|
+
jetty_dir
|
111
|
+
end
|
112
|
+
|
113
|
+
def install_jruby_rack_jar(vendor_dir)
|
114
|
+
download @settings.jruby_rack, File.join(vendor_dir, "jruby-rack.jar")
|
115
|
+
end
|
116
|
+
|
117
|
+
def process_template_files(erb_files)
|
118
|
+
erb_files.each do |erb_file|
|
119
|
+
evaled_contents = ERB.new(File.read(erb_file)).result(binding)
|
120
|
+
target_file = erb_file.sub(/\.erb$/, "")
|
121
|
+
File.open(target_file, "w"){|f|f<<evaled_contents}
|
122
|
+
File.new(target_file).chmod(File.stat(erb_file).mode)
|
123
|
+
rm erb_file
|
124
|
+
|
125
|
+
@created.delete(erb_file)
|
126
|
+
@created << target_file
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def note_files_created(dir)
|
131
|
+
before = Dir["#{dir}/**/{*,.*}"]
|
132
|
+
yield
|
133
|
+
after = Dir["#{dir}/**/{*,.*}"]
|
134
|
+
after - before
|
135
|
+
end
|
136
|
+
|
137
|
+
def overlay_files(overlay_dir, target_dir)
|
138
|
+
files_created = note_files_created(target_dir) do
|
139
|
+
x! "cp -pR #{overlay_dir}/ #{target_dir}/"
|
140
|
+
end
|
141
|
+
|
142
|
+
process_template_files files_created.select{|f|f=~/\.erb$/}
|
143
|
+
end
|
144
|
+
|
145
|
+
bin_dir = File.join(@path_to_project, "bin")
|
146
|
+
mkdir_p bin_dir
|
147
|
+
overlay_files File.join(@preflight_dir, "bin_files"), bin_dir
|
148
|
+
|
149
|
+
vendor_dir = File.join(@path_to_project, "vendor")
|
150
|
+
mkdir_p vendor_dir
|
151
|
+
download @settings.jruby, File.join(@path_to_project, @jruby_jar_file)
|
152
|
+
|
153
|
+
bundle_install if File.exists?(File.join(@path_to_project, "Gemfile.lock"))
|
154
|
+
if @settings.jetty?
|
155
|
+
jetty_dir = install_jetty(vendor_dir)
|
156
|
+
install_jruby_rack_jar vendor_dir #raise if jar not found
|
157
|
+
|
158
|
+
overlay_files File.join(@preflight_dir, "jetty_files"), File.join(@path_to_project, "vendor/jetty")
|
159
|
+
|
160
|
+
web_inf_dir = File.join(@path_to_project, "WEB-INF")
|
161
|
+
mkdir_p web_inf_dir
|
162
|
+
overlay_files File.join(@preflight_dir, "web_inf_files"), web_inf_dir
|
163
|
+
end
|
164
|
+
|
165
|
+
config_preflight_dir_in_project = File.join(@path_to_project, "config/preflight_files")
|
166
|
+
if File.directory?(config_preflight_dir_in_project)
|
167
|
+
overlay_files config_preflight_dir_in_project, @path_to_project
|
168
|
+
end
|
169
|
+
|
170
|
+
elapsed_seconds = (Time.now - script_start_time).to_i
|
171
|
+
|
172
|
+
puts %{Created:
|
173
|
+
#{@created.uniq.sort.join("\n ")}
|
174
|
+
Time: #{elapsed_seconds} s
|
175
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
#
|
4
|
+
# This file was generated by RubyGems.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
|
12
|
+
version = ">= 0"
|
13
|
+
|
14
|
+
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
|
15
|
+
version = $1
|
16
|
+
ARGV.shift
|
17
|
+
end
|
18
|
+
|
19
|
+
if File.exists?(File.expand_path('../../Gemfile.lock', __FILE__))
|
20
|
+
rake_line = `grep -E "rake \\\\([0-9]" Gemfile.lock`.chomp
|
21
|
+
if rake_line.length > 0
|
22
|
+
rake_line =~ /\((.*)\)/
|
23
|
+
$LOAD_PATH.unshift(File.expand_path("vendor/bundle/jruby/<%= @settings.ruby_version %>/gems/rake-#{$1}/lib"))
|
24
|
+
version = "= #{$1}"
|
25
|
+
loaded = true
|
26
|
+
require 'rake'
|
27
|
+
|
28
|
+
# Can't use Gem.bin_path below since rake hasn't been loaded as a gem.
|
29
|
+
Rake.application.run
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
unless loaded
|
34
|
+
gem 'rake', version
|
35
|
+
load Gem.bin_path('rake', 'rake', version)
|
36
|
+
end
|
data/bin_files/rake.erb
ADDED
data/bin_files/ruby.erb
ADDED
Binary file
|
Binary file
|
Binary file
|
data/install_gem.sh
ADDED
data/jetpack.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "jetpack"
|
5
|
+
s.version = "0.0.3"
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["Steve Conover"]
|
8
|
+
s.email = ["steve@squareup.com"]
|
9
|
+
s.homepage = "https://github.com/square/jetpack"
|
10
|
+
s.summary = %q{Jetpack prepares your jRuby project for jvm deployment.}
|
11
|
+
|
12
|
+
s.add_development_dependency "bundler"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
# s.executables = %w(bundle)
|
19
|
+
end
|
Binary file
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
3
|
+
|
4
|
+
<!-- =============================================================== -->
|
5
|
+
<!-- Configure the Jetty Server -->
|
6
|
+
<!-- -->
|
7
|
+
<!-- Documentation of this file format can be found at: -->
|
8
|
+
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
|
9
|
+
<!-- -->
|
10
|
+
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
|
11
|
+
<!-- and can be mixed in. For example: -->
|
12
|
+
<!-- java -jar start.jar etc/jetty-ssl.xml -->
|
13
|
+
<!-- -->
|
14
|
+
<!-- See start.ini file for the default configuraton files -->
|
15
|
+
<!-- =============================================================== -->
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
20
|
+
|
21
|
+
<Set name="ThreadPool">
|
22
|
+
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
|
23
|
+
<Set name="minThreads">10</Set>
|
24
|
+
<Set name="maxThreads"><%=@settings.max_concurrent_connections %></Set>
|
25
|
+
<Set name="detailedDump">false</Set>
|
26
|
+
</New>
|
27
|
+
</Set>
|
28
|
+
|
29
|
+
<Call name="addConnector">
|
30
|
+
<Arg>
|
31
|
+
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
|
32
|
+
<Set name="port"><%=@settings.https_port%></Set>
|
33
|
+
<Set name="maxIdleTime">30000</Set>
|
34
|
+
<Set name="password"><SystemProperty name="jetty.ssl.password" default="foobar" /></Set>
|
35
|
+
<Set name="keystore"><SystemProperty name="jetty.ssl.keystore" default="etc/fake.p12" /></Set>
|
36
|
+
<Set name="keystoreType">PKCS12</Set>
|
37
|
+
</New>
|
38
|
+
</Arg>
|
39
|
+
</Call>
|
40
|
+
|
41
|
+
<Call name="addConnector">
|
42
|
+
<Arg>
|
43
|
+
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
44
|
+
<Set name="port"><%=@settings.http_port%></Set>
|
45
|
+
<Set name="maxIdleTime">30000</Set>
|
46
|
+
</New>
|
47
|
+
</Arg>
|
48
|
+
</Call>
|
49
|
+
|
50
|
+
<!-- set the rails.env java system property based on the RAILS_ENV environment variable -->
|
51
|
+
<!-- this is used by jruby-rack to set Rails.env -->
|
52
|
+
<Call class="java.lang.System" name="setProperty">
|
53
|
+
<Arg>rails.env</Arg>
|
54
|
+
<Arg>
|
55
|
+
<Call class="java.lang.System" name="getenv">
|
56
|
+
<Arg>RAILS_ENV</Arg>
|
57
|
+
</Call>
|
58
|
+
</Arg>
|
59
|
+
</Call>
|
60
|
+
|
61
|
+
<Set name="handler">
|
62
|
+
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
63
|
+
<Set name="handlers">
|
64
|
+
<Array type="org.eclipse.jetty.server.Handler">
|
65
|
+
<Item>
|
66
|
+
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
67
|
+
</Item>
|
68
|
+
<Item>
|
69
|
+
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
70
|
+
</Item>
|
71
|
+
<Item>
|
72
|
+
|
73
|
+
<!-- Set up the webapp context for the rails root, which is ../../ from here -->
|
74
|
+
<New class="org.eclipse.jetty.webapp.WebAppContext">
|
75
|
+
<Arg><Ref id="Contexts"/></Arg>
|
76
|
+
<Arg>../../</Arg> <!-- "resource base" -->
|
77
|
+
<Arg>/</Arg> <!-- webapp root -->
|
78
|
+
<Set name="extraClasspath">../jruby.jar;../jruby-rack.jar</Set>
|
79
|
+
<!-- cp that makes ruby+rack work -->
|
80
|
+
</New>
|
81
|
+
</Item>
|
82
|
+
</Array>
|
83
|
+
</Set>
|
84
|
+
</New>
|
85
|
+
</Set>
|
86
|
+
|
87
|
+
<Set name="stopAtShutdown">true</Set>
|
88
|
+
<Set name="sendServerVersion">true</Set>
|
89
|
+
<Set name="sendDateHeader">true</Set>
|
90
|
+
<Set name="gracefulShutdown">1</Set>
|
91
|
+
<Set name="dumpAfterStart">false</Set>
|
92
|
+
<Set name="dumpBeforeStop">false</Set>
|
93
|
+
|
94
|
+
<Ref id="Handlers">
|
95
|
+
<Call name="addHandler">
|
96
|
+
<Arg>
|
97
|
+
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
|
98
|
+
<Set name="requestLog">
|
99
|
+
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
|
100
|
+
<Set name="filename">../../log/jetty_request_yyyy_mm_dd.log</Set>
|
101
|
+
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
|
102
|
+
<Set name="retainDays">90</Set>
|
103
|
+
<Set name="append">true</Set>
|
104
|
+
<Set name="extended">false</Set>
|
105
|
+
<Set name="logCookies">false</Set>
|
106
|
+
<Set name="LogTimeZone">GMT</Set>
|
107
|
+
</New>
|
108
|
+
</Set>
|
109
|
+
</New>
|
110
|
+
</Arg>
|
111
|
+
</Call>
|
112
|
+
</Ref>
|
113
|
+
</Configure>
|