Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Jetpack with Capistrano and external jar dependencies #11

Closed
wants to merge 3 commits into from

3 participants

Jonathan Palley Xavier Shay Michael D'Auria
Jonathan Palley

Note: this is our first time using Jetty. These fixes allowed us to use jetpack with capistrano and other jar dependencies. If not suitable/correct pls let us know!

  1. Removes RAILS_ENV requirement in jetty-init if app_type is not rails.
  2. Uses @path_to_project for the bundler gem. Given we are setting this anyway and thus have the fullpath, it seemed easier than try to make sure $PATH was setup correctly.
  3. Adds jar_includes to the jetpack.yml file to allow extra jar files to be included. These are inserted into the extraClasspath of the jetty.xml after the jruby jar files.
Michael D'Auria michaeldauria commented on the diff
bin/jetpack
@@ -53,7 +53,7 @@ script_start_time = Time.now
@jetpack_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
@gem_home = "file:" + File.expand_path(File.join(@settings.app_root, @jruby_jar_file)) + "!/META-INF/jruby.home/lib/ruby/gems/1.8"
-@gem_path = @gem_home + ":vendor/bundler_gem"
+@gem_path = @gem_home + ":#{File.expand_path(File.join(@path_to_project, "vendor/bundler_gem"))}"

if you're going to use File.join, might as well go all the way with it:

@gem_path = @gem_home + ':' + File.expand_path(File.join(@path_to_project, 'vendor', 'bundler_gem'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Xavier Shay
Admin

Closing stale. Sorry this got ignored. Feel free to rebase and resubmit if it's still relevant.

Xavier Shay xaviershay closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  bin/jetpack
View
@@ -53,7 +53,7 @@ script_start_time = Time.now
@jetpack_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
@gem_home = "file:" + File.expand_path(File.join(@settings.app_root, @jruby_jar_file)) + "!/META-INF/jruby.home/lib/ruby/gems/1.8"
-@gem_path = @gem_home + ":vendor/bundler_gem"
+@gem_path = @gem_home + ":#{File.expand_path(File.join(@path_to_project, "vendor/bundler_gem"))}"

if you're going to use File.join, might as well go all the way with it:

@gem_path = @gem_home + ':' + File.expand_path(File.join(@path_to_project, 'vendor', 'bundler_gem'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@java_dash_jar = "PATH=$PATH:$(dirname $0) GEM_HOME=\"#{@gem_home}\" GEM_PATH=\"#{@gem_path}\" exec java #{@settings.java_options} -jar"
@jruby_opts = @settings.ruby_version.to_s == '1.9' ? '--1.9' : ''
2  jetty_files/etc/jetty.xml.erb
View
@@ -88,7 +88,7 @@
<Arg><Ref id="Contexts"/></Arg>
<Arg><Property name="jetty.home"/>/../../</Arg> <!-- "resource base" -->
<Arg>/</Arg> <!-- webapp root -->
- <Set name="extraClasspath"><Property name="jetty.home"/>/../jruby.jar;<Property name="jetty.home"/>/../jruby-rack.jar</Set>
+ <Set name="extraClasspath"><Property name="jetty.home"/>/../jruby.jar;<Property name="jetty.home"/>/../jruby-rack.jar;<%= @settings.jar_includes %></Set>
<!-- cp that makes ruby+rack work -->
</New>
</Item>
9 jetty_files/jetty-init.erb
View
@@ -135,7 +135,7 @@ running()
ps -p $PID >/dev/null 2>/dev/null || return 1
return 0
}
-
+<% if @settings.rails? %>
ensure_rails_env_set()
{
if [ -z "$RAILS_ENV" ]; then
@@ -143,6 +143,7 @@ ensure_rails_env_set()
exit 1
fi
}
+<% end %>
@@ -532,7 +533,9 @@ RUN_CMD="$JAVA $RUN_ARGS"
##################################################
case "$ACTION" in
start)
+ <% if @settings.rails? %>
ensure_rails_env_set
+ <% end %>
echo -n "Starting Jetty: "
if [ "$NO_START" = "1" ]; then
@@ -629,8 +632,10 @@ case "$ACTION" in
;;
restart)
+ <% if @settings.rails? %>
ensure_rails_env_set
- JETTY_SH=$0
+ <% end %>
+ JETTY_SH=$0
if [ ! -f $JETTY_SH ]; then
if [ ! -f $JETTY_HOME/bin/jetty.sh ]; then
echo "$JETTY_HOME/bin/jetty.sh does not exist."
2  lib/jetpack/settings.rb
View
@@ -25,7 +25,7 @@ def initialize(project_dir, user_defined_options)
contents["ruby_version"] = user_defined_options["ruby_version"] || "1.8"
contents["app_type"] = user_defined_options["app_type"] || "rails"
contents["environment"] = user_defined_options["environment"] || nil
-
+ contents["jar_includes"] = user_defined_options["jar_includes"] || ""
@keys = contents.keys.sort
super(contents)
Something went wrong with that request. Please try again.