Skip to content

Configuring jettywrapper

Mark Bussey edited this page Oct 27, 2015 · 6 revisions

These instructions assume that you want to work with jettywrapper via its rake tasks, so the ruby snippets below are meant to be added to your project's Rakefile, along with require 'jettywrapper'.

There are a number of configuration options available, such as which port to use, how long to wait for jetty to start up, where to put the jetty instance, what zip to use as a jetty instance. The options available are in lib/jettywrapper.rb.

Default settings

The default settings for configuration options are in lib/jettywrapper.rb.

Jetty instance

hydra-jetty

By default, Jettywrapper is designed to use hydra-jetty (Solr + Fedora). You can specify the version of hydra-jetty to be used (i.e. which versions of Fedora and Solr) by adding the following to a rake task:

  Jettywrapper.hydra_jetty_version = "v6.6.6"

The version number must be an existing release zip file for hydra-jetty.

or you can specify Jettywrapper.url in your rake task (which will take precedence over ZIP_URL):

Jettywrapper.url = "https://github.com/myorg/my-jetty/archive/v6.6.6.zip"

other jettys

You can use any Jetty-based zip file by specifying ZIP_URL in your Rakefile:

ZIP_URL = "https://github.com/myorg/my-jetty/archive/v6.6.6.zip"

A common need is for a Solr only jetty, which is available from blacklight-jetty as a release zip file corresponding to a particular Solr version.

ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.4.zip"

You can also specify an existing zip file by setting the ENV variable JETTY_ZIP at the command line:

$ JETTY_ZIP="tmp/v6.6.6.zip" rake jetty:download

config/jetty.yml

Jettywrapper will look for configuration information in your project's config/jetty.yml file. You can have a default configuration which will be used when a per-environment configuration is not specified. For example, config/jetty.yml might look like:

default:
  jetty_port: 8983
  java_opts:
    - "-XX:MaxPermSize=128m"
    - "-Xmx256m"

Or you can provide a per-environment configuration, such as is used in a Rails app:

development:
  startup_wait: 15
  jetty_port: 8983
  java_version: ">= 1.7"
test:
  startup_wait: 60
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
  java_version: ">= 1.7"

these config options are read by Jettywrapper.load_config, which may be included as an instruction in a rake task in your project:

require 'jettywrapper'
ZIP_URL = "https://github.com/myorg/my-jetty/archive/v6.6.6.zip"

desc "Run Tests"
task :ci do
  jetty_params = Jettywrapper.load_config
  error = nil
  error = Jettywrapper.wrap(jetty_params) do
    Rake::Task['spec'].invoke
  end
  raise "test failures: #{error}" if error
end

hash passed to Jettywrapper method

You can see above that you can directly set config values in a hash passed to a Jettywrapper method, e.g.

jetty_params = Jettywrapper.load_config.merge!({jetty_port: 8983, startup_wait: 15})
Jettywrapper.start(jetty_params)

command line options

To use the rake tasks for this, you may need to set up your config/jetty.yml file to look for variables from env:

default:
  jetty_port: <%= ENV['JETTY_PORT'] || 8888 %>
  java_version: ">= 1.7"

and then use those variables at the command line:

JETTY_PORT=8983 rake jetty:start