You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Michael J. Giarlo edited this page Oct 9, 2015
·
4 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'.
Jetty can take quite a while to spin up, especially if it is starting Fedora and Solr as well, per hydra-jetty. For testing, it can be prudent to allow 60 seconds or more for jetty to spin up, especially on a Continuous Integration server. This is accomplished by setting startup_wait in config/jetty.yml:
Sometimes jetty doesn't shut down properly. One way this can be caused is by interrupting the process using Jettywrapper.wrap, such as running your tests. It is also common to forget that you spun it up manually, or not realize that it didn't shut down.
Sometimes the first you are made aware of it is when your tests fail due to unexpected data conditions, or your dev instance is behaving oddly.
There is a rake task provided to help with this:
rake jetty:status
Or you can check your system directly:
$ ps -eaf | grep jetty
If there is a jetty process running, you can stop it with:
$ rake jetty:stop
If that doesn't work, you can always use the nuclear option and kill jetty manually:
$ pkill -f jetty
What rake tasks are provided by jettywrapper?
To use jettywrapper's rake tasks, in your project's Rakefile add:
require'jettywrapper'
then run
rake -T
and you will see a number of rake tasks in the jetty namespace.
Working with the zip file
Jettywrapper is designed to expect a packaged jetty instance in a zip file with the web services needed by your project.
The presumption is that you want to download the zip file rarely, but you may want to reset your project's jetty instance as part of testing.
rake jetty:download # download the jetty zip file
rake jetty:unzip # unzip the downloaded jetty archive
This is often one-time setup for a project using jettywrapper.
Setting up jetty for your project
In addition to any configuration params you want to indicate to jettywrapper (see Configuring jettywrapper), you may need to copy project specific configurations to the web services in the jetty instance.
Since you may want to be able to reset your jetty instance to a pristine state as part of testing, it is generally useful to set up a rake task to do this configuration:
namespace:myprojdesc'Copies the default SOLR config for the bundled Testing Server'task:configure_jettydoFileList['solr_conf/conf/*'].eachdo |f|
cp("#{f}",'jetty/solr/blacklight-core/conf/',verbose: true)endendend
Starting jetty
$ rake jetty:start
If jetty is already running, there is a task to stop it and restart it:
$ rake jetty:restart
but see Gotcha section above.
Stopping jetty
$ rake jetty:stop
but see Gotcha section above.
Wrapping your code
The Jettywrapper.wrap method will start the jetty server before a block of code and stop the server after the block, which is especially useful for automated testing.
An example rake task:
require'jettywrapper'desc'run the tests for continuous integration'taskci: ['jetty:clean','myproj:configure_jetty']doENV['environment']='test'jetty_params=Jettywrapper.load_configjetty_params[:startup_wait]=60error=nilerror=Jettywrapper.wrap(jetty_params)do# run the testsRake::Task['spec'].invokeendraise"test failures: #{error}"iferrorend
Resetting Jetty to pristine state
$ rake jetty:clean
The jetty:clean rake task resets Jetty to a pristine state. It does this by removing the existing instance of Jetty in your project, then unzipping the downloaded zip file with jetty. This also wipes out any project specify changes you made to the jetty instance. You might want a rake task like this:
namespace:myprojdesc'wipe and reset jetty'taskjetty_reset: ['jetty:clean','myproj:configure_jetty']end