jettywrapper 1.4.0 → 1.8.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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/CONTRIBUTING.md +113 -0
- data/History.txt +3 -0
- data/README.textile +2 -9
- data/jettywrapper.gemspec +3 -7
- data/lib/jettywrapper/version.rb +3 -1
- data/lib/jettywrapper.rb +199 -180
- data/lib/tasks/jettywrapper.rake +2 -0
- data/spec/lib/jettywrapper_integration_spec.rb +2 -2
- data/spec/lib/jettywrapper_spec.rb +105 -26
- data/spec/spec_helper.rb +1 -1
- metadata +31 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7d661a0b7e7c0b5237898916aa1a4c7a325f2ce
|
|
4
|
+
data.tar.gz: a2e348d77b9c9a9532fa7aa9d6633c37dfc7ec7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a63cd1bd6ef04567f343e5e222a4764b5b0be3c735e70de32b61acf1084d4330b86ff8633863fb31445a9ae2399ca16a4fd2ac6de3b63809f496d83672aff5a
|
|
7
|
+
data.tar.gz: c25b1b9f5ff6290b76708bdc7857c3d15440b9db29091872a51dd11eb6ac141309af8caff1c368932d9158dd2426e399c55c3b7e25eb98c1d5a3f25ea2a95834
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# How to Contribute
|
|
2
|
+
|
|
3
|
+
We want your help to make Project Hydra great.
|
|
4
|
+
There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
|
5
|
+
|
|
6
|
+
## Hydra Project Intellectual Property Licensing and Ownership
|
|
7
|
+
|
|
8
|
+
All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
|
|
9
|
+
If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
|
|
10
|
+
|
|
11
|
+
https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
|
|
12
|
+
|
|
13
|
+
You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
|
|
14
|
+
|
|
15
|
+
## Contribution Tasks
|
|
16
|
+
|
|
17
|
+
* Reporting Issues
|
|
18
|
+
* Making Changes
|
|
19
|
+
* Submitting Changes
|
|
20
|
+
* Merging Changes
|
|
21
|
+
|
|
22
|
+
### Reporting Issues
|
|
23
|
+
|
|
24
|
+
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
|
25
|
+
* Submit a [Github issue](./issues) by:
|
|
26
|
+
* Clearly describing the issue
|
|
27
|
+
* Provide a descriptive summary
|
|
28
|
+
* Explain the expected behavior
|
|
29
|
+
* Explain the actual behavior
|
|
30
|
+
* Provide steps to reproduce the actual behavior
|
|
31
|
+
|
|
32
|
+
### Making Changes
|
|
33
|
+
|
|
34
|
+
* Fork the repository on GitHub
|
|
35
|
+
* Create a topic branch from where you want to base your work.
|
|
36
|
+
* This is usually the master branch.
|
|
37
|
+
* To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
|
|
38
|
+
* Then checkout the new branch with `git checkout fix/master/my_contribution`.
|
|
39
|
+
* Please avoid working directly on the `master` branch.
|
|
40
|
+
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
|
41
|
+
* Make commits of logical units.
|
|
42
|
+
* Your commit should include a high level description of your work in HISTORY.textile
|
|
43
|
+
* Check for unnecessary whitespace with `git diff --check` before committing.
|
|
44
|
+
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
|
45
|
+
* If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
Present tense short summary (50 characters or less)
|
|
49
|
+
|
|
50
|
+
More detailed description, if necessary. It should be wrapped to 72
|
|
51
|
+
characters. Try to be as descriptive as you can, even if you think that
|
|
52
|
+
the commit content is obvious, it may not be obvious to others. You
|
|
53
|
+
should add such description also if it's already present in bug tracker,
|
|
54
|
+
it should not be necessary to visit a webpage to check the history.
|
|
55
|
+
|
|
56
|
+
Include Closes #<issue-number> when relavent.
|
|
57
|
+
|
|
58
|
+
Description can have multiple paragraphs and you can use code examples
|
|
59
|
+
inside, just indent it with 4 spaces:
|
|
60
|
+
|
|
61
|
+
class PostsController
|
|
62
|
+
def index
|
|
63
|
+
respond_with Post.limit(10)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
You can also add bullet points:
|
|
68
|
+
|
|
69
|
+
- you can use dashes or asterisks
|
|
70
|
+
|
|
71
|
+
- also, try to indent next line of a point for readability, if it's too
|
|
72
|
+
long to fit in 72 characters
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
* Make sure you have added the necessary tests for your changes.
|
|
76
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
|
77
|
+
* When you are ready to submit a pull request
|
|
78
|
+
|
|
79
|
+
### Submitting Changes
|
|
80
|
+
|
|
81
|
+
[Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
|
82
|
+
|
|
83
|
+
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
|
84
|
+
* Make sure your branch is up to date with its parent branch (i.e. master)
|
|
85
|
+
* `git checkout master`
|
|
86
|
+
* `git pull --rebase`
|
|
87
|
+
* `git checkout <your-branch>`
|
|
88
|
+
* `git rebase master`
|
|
89
|
+
* It is likely a good idea to run your tests again.
|
|
90
|
+
* Squash the commits for your branch into one commit
|
|
91
|
+
* `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
|
92
|
+
* To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
|
|
93
|
+
* Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
|
|
94
|
+
* Push your changes to a topic branch in your fork of the repository.
|
|
95
|
+
* Submit a pull request from your fork to the project.
|
|
96
|
+
|
|
97
|
+
### Merging Changes
|
|
98
|
+
|
|
99
|
+
* It is considered "poor from" to merge your own request.
|
|
100
|
+
* Please take the time to review the changes and get a sense of what is being changed. Things to consider:
|
|
101
|
+
* Does the commit message explain what is going on?
|
|
102
|
+
* Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
|
|
103
|
+
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
|
104
|
+
* Did the Travis tests complete successfully?
|
|
105
|
+
* If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
|
|
106
|
+
* If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
|
|
107
|
+
|
|
108
|
+
# Additional Resources
|
|
109
|
+
|
|
110
|
+
* [General GitHub documentation](http://help.github.com/)
|
|
111
|
+
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
|
112
|
+
* [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
|
113
|
+
* [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/History.txt
CHANGED
data/README.textile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
h1. jettywrapper
|
|
2
2
|
|
|
3
|
+
!https://travis-ci.org/projecthydra/jettywrapper.png?branch=master!:https://travis-ci.org/projecthydra/jettywrapper
|
|
3
4
|
|
|
4
5
|
This gem is designed to make it easier to integrate a jetty servlet container into a rails project.
|
|
5
6
|
Jettywrapper provides rake tasks for starting and stopping jetty, as well as a method (Jettywrapper.wrap) that will start the server before the block and stop the server after the block, which is useful for automated testing.
|
|
@@ -45,19 +46,11 @@ If you haven't already, clone the git repository
|
|
|
45
46
|
cd jettywrapper
|
|
46
47
|
</pre>
|
|
47
48
|
|
|
48
|
-
If you're using RVM (recommended), use the .rvmrc
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
source .rvmrc
|
|
52
|
-
rvm list gemsets
|
|
53
|
-
</pre>
|
|
54
|
-
|
|
55
|
-
Install the gems and pull the submodules
|
|
50
|
+
Install the gems
|
|
56
51
|
|
|
57
52
|
<pre>
|
|
58
53
|
bundle install
|
|
59
|
-
git submodule init
|
|
60
|
-
git submodule update
|
|
61
54
|
</pre>
|
|
62
55
|
|
|
63
56
|
Run the tests
|
data/jettywrapper.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ require 'bundler'
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "jettywrapper"
|
|
8
|
-
s.version =
|
|
8
|
+
s.version = Jettywrapper::VERSION
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
|
10
10
|
s.authors = ["Chris Beer", "Justin Coyne", "Bess Sadler"]
|
|
11
11
|
s.email = ["hydra-tech@googlegroups.com"]
|
|
@@ -20,20 +20,16 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.required_rubygems_version = ">= 1.3.6"
|
|
21
21
|
|
|
22
22
|
s.add_dependency "logger"
|
|
23
|
-
s.add_dependency "mediashelf-loggable"
|
|
24
23
|
s.add_dependency "childprocess"
|
|
25
24
|
s.add_dependency "i18n"
|
|
26
25
|
s.add_dependency "activesupport", ">=3.0.0"
|
|
27
26
|
|
|
28
|
-
s.add_development_dependency "rspec"
|
|
27
|
+
s.add_development_dependency "rspec", '~> 2.99'
|
|
28
|
+
s.add_development_dependency "rspec-its"
|
|
29
29
|
s.add_development_dependency 'rake'
|
|
30
|
-
|
|
31
30
|
|
|
32
31
|
s.add_development_dependency 'yard'#, '0.6.5' # Yard > 0.6.5 won't generate docs.
|
|
33
32
|
# I don't know why & don't have time to
|
|
34
33
|
# debug it right now
|
|
35
|
-
|
|
36
|
-
s.add_development_dependency 'RedCloth'
|
|
37
|
-
|
|
38
34
|
end
|
|
39
35
|
|
data/lib/jettywrapper/version.rb
CHANGED
data/lib/jettywrapper.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'loggable'
|
|
2
1
|
require 'singleton'
|
|
3
2
|
require 'fileutils'
|
|
4
3
|
require 'shellwords'
|
|
@@ -16,7 +15,6 @@ Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |
|
|
|
16
15
|
class Jettywrapper
|
|
17
16
|
|
|
18
17
|
include Singleton
|
|
19
|
-
include Loggable
|
|
20
18
|
include ActiveSupport::Benchmarkable
|
|
21
19
|
|
|
22
20
|
|
|
@@ -39,37 +37,35 @@ class Jettywrapper
|
|
|
39
37
|
# Methods outside the class << self block must be called on Jettywrapper.instance, as instance methods.
|
|
40
38
|
class << self
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
attr_writer :hydra_jetty_version, :url, :tmp_dir, :jetty_dir, :env
|
|
41
|
+
|
|
42
|
+
def hydra_jetty_version
|
|
43
|
+
@hydra_jetty_version ||= 'v7.0.0'
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def url
|
|
47
|
-
@url ||= defined?(ZIP_URL) ? ZIP_URL :
|
|
47
|
+
@url ||= defined?(ZIP_URL) ? ZIP_URL : "https://github.com/projecthydra/hydra-jetty/archive/#{hydra_jetty_version}.zip"
|
|
48
48
|
@url
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def tmp_dir=(dir)
|
|
52
|
-
@tmp_dir = dir
|
|
53
|
-
end
|
|
54
|
-
|
|
55
51
|
def tmp_dir
|
|
56
52
|
@tmp_dir ||= 'tmp'
|
|
57
53
|
end
|
|
58
54
|
|
|
59
55
|
def zip_file
|
|
60
|
-
File.join
|
|
56
|
+
ENV['JETTY_ZIP'] || File.join(tmp_dir, url.split('/').last)
|
|
61
57
|
end
|
|
62
58
|
|
|
63
59
|
def jetty_dir
|
|
64
|
-
'jetty'
|
|
60
|
+
@jetty_dir ||= 'jetty'
|
|
65
61
|
end
|
|
66
62
|
|
|
67
|
-
def download(url =
|
|
68
|
-
self.url = url
|
|
69
|
-
logger.info "Downloading jetty..."
|
|
63
|
+
def download(url = nil)
|
|
64
|
+
self.url = url if url
|
|
65
|
+
logger.info "Downloading jetty at #{self.url} ..."
|
|
70
66
|
FileUtils.mkdir tmp_dir unless File.exists? tmp_dir
|
|
71
|
-
system "curl -L #{url} -o #{zip_file}"
|
|
72
|
-
abort "Unable to download jetty from #{url}" unless $?.success?
|
|
67
|
+
system "curl -L #{self.url} -o #{zip_file}"
|
|
68
|
+
abort "Unable to download jetty from #{self.url}" unless $?.success?
|
|
73
69
|
end
|
|
74
70
|
|
|
75
71
|
def unzip
|
|
@@ -79,6 +75,10 @@ class Jettywrapper
|
|
|
79
75
|
system "unzip -d #{tmp_save_dir} -qo #{zip_file}"
|
|
80
76
|
abort "Unable to unzip #{zip_file} into tmp_save_dir/" unless $?.success?
|
|
81
77
|
|
|
78
|
+
# Remove the old jetty directory if it exists
|
|
79
|
+
system "rm -r #{jetty_dir}" if File.directory?(jetty_dir)
|
|
80
|
+
|
|
81
|
+
# Move the expanded zip file into the final destination.
|
|
82
82
|
expanded_dir = expanded_zip_dir(tmp_save_dir)
|
|
83
83
|
system "mv #{expanded_dir} #{jetty_dir}"
|
|
84
84
|
abort "Unable to move #{expanded_dir} into #{jetty_dir}/" unless $?.success?
|
|
@@ -97,27 +97,41 @@ class Jettywrapper
|
|
|
97
97
|
|
|
98
98
|
def reset_config
|
|
99
99
|
@app_root = nil
|
|
100
|
+
@env = nil
|
|
101
|
+
@url = nil
|
|
102
|
+
@hydra_jetty_version = nil
|
|
100
103
|
end
|
|
101
104
|
|
|
102
105
|
def app_root
|
|
103
106
|
return @app_root if @app_root
|
|
104
|
-
if defined?(Rails.root)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
@app_root = Rails.root if defined?(Rails) and defined?(Rails.root)
|
|
108
|
+
@app_root ||= APP_ROOT if defined?(APP_ROOT)
|
|
109
|
+
@app_root ||= '.'
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def env
|
|
113
|
+
@env ||= begin
|
|
114
|
+
case
|
|
115
|
+
when ENV['JETTYWRAPPER_ENV']
|
|
116
|
+
ENV['JETTYWRAPPER_ENV']
|
|
117
|
+
when defined?(Rails) && Rails.respond_to?(:env)
|
|
118
|
+
Rails.env
|
|
119
|
+
when ENV['RAILS_ENV']
|
|
120
|
+
ENV['RAILS_ENV']
|
|
121
|
+
when ENV['environment']
|
|
122
|
+
ENV['environment']
|
|
123
|
+
else
|
|
124
|
+
default_environment
|
|
125
|
+
end
|
|
110
126
|
end
|
|
111
|
-
@app_root
|
|
112
127
|
end
|
|
113
128
|
|
|
114
|
-
def
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
def default_environment
|
|
130
|
+
'development'
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def load_config(config_name = env)
|
|
134
|
+
@env = config_name
|
|
121
135
|
jetty_file = "#{app_root}/config/jetty.yml"
|
|
122
136
|
|
|
123
137
|
unless File.exists?(jetty_file)
|
|
@@ -126,23 +140,23 @@ class Jettywrapper
|
|
|
126
140
|
end
|
|
127
141
|
|
|
128
142
|
begin
|
|
129
|
-
|
|
130
|
-
rescue
|
|
143
|
+
jetty_erb = ERB.new(IO.read(jetty_file)).result(binding)
|
|
144
|
+
rescue
|
|
131
145
|
raise("jetty.yml was found, but could not be parsed with ERB. \n#{$!.inspect}")
|
|
132
146
|
end
|
|
133
147
|
|
|
134
148
|
begin
|
|
135
|
-
|
|
136
|
-
rescue
|
|
149
|
+
jetty_yml = YAML::load(jetty_erb)
|
|
150
|
+
rescue
|
|
137
151
|
raise("jetty.yml was found, but could not be parsed.\n")
|
|
138
152
|
end
|
|
139
153
|
|
|
140
|
-
if
|
|
154
|
+
if jetty_yml.nil? || !jetty_yml.is_a?(Hash)
|
|
141
155
|
raise("jetty.yml was found, but was blank or malformed.\n")
|
|
142
156
|
end
|
|
143
157
|
|
|
144
|
-
config =
|
|
145
|
-
config[config_name] || config[
|
|
158
|
+
config = jetty_yml.with_indifferent_access
|
|
159
|
+
config[config_name] || config['default'.freeze]
|
|
146
160
|
end
|
|
147
161
|
|
|
148
162
|
|
|
@@ -159,14 +173,8 @@ class Jettywrapper
|
|
|
159
173
|
jetty_server = self.instance
|
|
160
174
|
jetty_server.reset_process!
|
|
161
175
|
jetty_server.quiet = params[:quiet].nil? ? true : params[:quiet]
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
elsif defined?(APP_ROOT)
|
|
165
|
-
base_path = APP_ROOT
|
|
166
|
-
else
|
|
167
|
-
raise "You must set either Rails.root, APP_ROOT or pass :jetty_home as a parameter so I know where jetty is" unless params[:jetty_home]
|
|
168
|
-
end
|
|
169
|
-
jetty_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(base_path, 'jetty'))
|
|
176
|
+
|
|
177
|
+
jetty_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(app_root, 'jetty'))
|
|
170
178
|
jetty_server.solr_home = params[:solr_home] || File.join( jetty_server.jetty_home, "solr")
|
|
171
179
|
jetty_server.port = params[:jetty_port] || 8888
|
|
172
180
|
jetty_server.startup_wait = params[:startup_wait] || 5
|
|
@@ -294,156 +302,167 @@ class Jettywrapper
|
|
|
294
302
|
return false
|
|
295
303
|
end
|
|
296
304
|
end
|
|
305
|
+
|
|
306
|
+
def logger=(logger)
|
|
307
|
+
@@logger = logger
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# If ::Rails.logger is defined, that will be returned.
|
|
311
|
+
# If no logger has been defined, a new STDOUT Logger will be created.
|
|
312
|
+
def logger
|
|
313
|
+
@@logger ||= defined?(::Rails) ? ::Rails.logger : ::Logger.new(STDOUT)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
end #end of class << self
|
|
297
317
|
|
|
298
|
-
|
|
299
|
-
|
|
318
|
+
def logger
|
|
319
|
+
self.class.logger
|
|
320
|
+
end
|
|
300
321
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
# Start the jetty server. Check the pid file to see if it is running already,
|
|
312
|
-
# and stop it if so. After you start jetty, write the PID to a file.
|
|
313
|
-
# This is the instance start method. It must be called on Jettywrapper.instance
|
|
314
|
-
# You're probably better off using Jettywrapper.start(:jetty_home => "/path/to/jetty")
|
|
315
|
-
# @example
|
|
316
|
-
# Jettywrapper.configure(params)
|
|
317
|
-
# Jettywrapper.instance.start
|
|
318
|
-
# return Jettywrapper.instance
|
|
319
|
-
def start
|
|
320
|
-
logger.debug "Starting jetty with these values: "
|
|
321
|
-
logger.debug "jetty_home: #{@jetty_home}"
|
|
322
|
-
logger.debug "jetty_command: #{jetty_command.join(' ')}"
|
|
323
|
-
|
|
324
|
-
# Check to see if we can start.
|
|
325
|
-
# 1. If there is a pid, check to see if it is really running
|
|
326
|
-
# 2. Check to see if anything is blocking the port we want to use
|
|
327
|
-
if pid
|
|
328
|
-
if Jettywrapper.is_pid_running?(pid)
|
|
329
|
-
raise("Server is already running with PID #{pid}")
|
|
330
|
-
else
|
|
331
|
-
logger.warn "Removing stale PID file at #{pid_path}"
|
|
332
|
-
File.delete(pid_path)
|
|
333
|
-
end
|
|
334
|
-
end
|
|
335
|
-
if Jettywrapper.is_port_in_use?(self.port)
|
|
336
|
-
raise("Port #{self.port} is already in use.")
|
|
337
|
-
end
|
|
338
|
-
benchmark "Started jetty" do
|
|
339
|
-
Dir.chdir(@jetty_home) do
|
|
340
|
-
process.start
|
|
341
|
-
end
|
|
342
|
-
FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
|
|
343
|
-
begin
|
|
344
|
-
f = File.new(pid_path, "w")
|
|
345
|
-
rescue Errno::ENOENT, Errno::EACCES
|
|
346
|
-
f = File.new(File.join(base_path,'tmp',pid_file),"w")
|
|
347
|
-
end
|
|
348
|
-
f.puts "#{process.pid}"
|
|
349
|
-
f.close
|
|
350
|
-
logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
|
|
351
|
-
startup_wait!
|
|
352
|
-
end
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
# Wait for the jetty server to start and begin listening for requests
|
|
356
|
-
def startup_wait!
|
|
357
|
-
begin
|
|
358
|
-
Timeout::timeout(startup_wait) do
|
|
359
|
-
sleep 1 until (Jettywrapper.is_port_in_use? self.port)
|
|
360
|
-
end
|
|
361
|
-
rescue Timeout::Error
|
|
362
|
-
logger.warn "Waited #{startup_wait} seconds for jetty to start, but it is not yet listening on port #{self.port}. Continuing anyway."
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
def process
|
|
367
|
-
@process ||= begin
|
|
368
|
-
process = ChildProcess.build(*jetty_command)
|
|
369
|
-
if self.quiet
|
|
370
|
-
process.io.stderr = File.open(File.expand_path("jettywrapper.log"), "w+")
|
|
371
|
-
process.io.stdout = process.io.stderr
|
|
372
|
-
logger.warn "Logging jettywrapper stdout to #{File.expand_path(process.io.stderr.path)}"
|
|
373
|
-
else
|
|
374
|
-
process.io.inherit!
|
|
375
|
-
end
|
|
376
|
-
process.detach = true
|
|
322
|
+
# What command is being run to invoke jetty?
|
|
323
|
+
def jetty_command
|
|
324
|
+
["java", java_variables, java_opts, "-jar", "start.jar", jetty_opts].flatten
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def java_variables
|
|
328
|
+
["-Djetty.port=#{@port}",
|
|
329
|
+
"-Dsolr.solr.home=#{Shellwords.escape(@solr_home)}"]
|
|
330
|
+
end
|
|
377
331
|
|
|
378
|
-
|
|
332
|
+
# Start the jetty server. Check the pid file to see if it is running already,
|
|
333
|
+
# and stop it if so. After you start jetty, write the PID to a file.
|
|
334
|
+
# This is the instance start method. It must be called on Jettywrapper.instance
|
|
335
|
+
# You're probably better off using Jettywrapper.start(:jetty_home => "/path/to/jetty")
|
|
336
|
+
# @example
|
|
337
|
+
# Jettywrapper.configure(params)
|
|
338
|
+
# Jettywrapper.instance.start
|
|
339
|
+
# return Jettywrapper.instance
|
|
340
|
+
def start
|
|
341
|
+
logger.debug "Starting jetty with these values: "
|
|
342
|
+
logger.debug "jetty_home: #{@jetty_home}"
|
|
343
|
+
logger.debug "jetty_command: #{jetty_command.join(' ')}"
|
|
344
|
+
|
|
345
|
+
# Check to see if we can start.
|
|
346
|
+
# 1. If there is a pid, check to see if it is really running
|
|
347
|
+
# 2. Check to see if anything is blocking the port we want to use
|
|
348
|
+
if pid
|
|
349
|
+
if Jettywrapper.is_pid_running?(pid)
|
|
350
|
+
raise("Server is already running with PID #{pid}")
|
|
351
|
+
else
|
|
352
|
+
logger.warn "Removing stale PID file at #{pid_path}"
|
|
353
|
+
File.delete(pid_path)
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
if Jettywrapper.is_port_in_use?(self.port)
|
|
357
|
+
raise("Port #{self.port} is already in use.")
|
|
358
|
+
end
|
|
359
|
+
benchmark "Started jetty" do
|
|
360
|
+
Dir.chdir(@jetty_home) do
|
|
361
|
+
process.start
|
|
362
|
+
end
|
|
363
|
+
FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
|
|
364
|
+
begin
|
|
365
|
+
f = File.new(pid_path, "w")
|
|
366
|
+
rescue Errno::ENOENT, Errno::EACCES
|
|
367
|
+
f = File.new(File.join(base_path,'tmp',pid_file),"w")
|
|
379
368
|
end
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
369
|
+
f.puts "#{process.pid}"
|
|
370
|
+
f.close
|
|
371
|
+
logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
|
|
372
|
+
startup_wait!
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
# Wait for the jetty server to start and begin listening for requests
|
|
377
|
+
def startup_wait!
|
|
378
|
+
begin
|
|
379
|
+
Timeout::timeout(startup_wait) do
|
|
380
|
+
sleep 1 until (Jettywrapper.is_port_in_use? self.port)
|
|
381
|
+
end
|
|
382
|
+
rescue Timeout::Error
|
|
383
|
+
logger.warn "Waited #{startup_wait} seconds for jetty to start, but it is not yet listening on port #{self.port}. Continuing anyway."
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def process
|
|
388
|
+
@process ||= begin
|
|
389
|
+
process = ChildProcess.build(*jetty_command)
|
|
390
|
+
if self.quiet
|
|
391
|
+
process.io.stderr = File.open(File.expand_path("jettywrapper.log"), "w+")
|
|
392
|
+
process.io.stdout = process.io.stderr
|
|
393
|
+
logger.warn "Logging jettywrapper stdout to #{File.expand_path(process.io.stderr.path)}"
|
|
396
394
|
else
|
|
397
|
-
|
|
395
|
+
process.io.inherit!
|
|
398
396
|
end
|
|
397
|
+
process.detach = true
|
|
399
398
|
|
|
400
|
-
|
|
401
|
-
File.delete(pid_path)
|
|
402
|
-
rescue
|
|
403
|
-
end
|
|
399
|
+
process
|
|
404
400
|
end
|
|
405
|
-
|
|
406
|
-
|
|
401
|
+
end
|
|
407
402
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
403
|
+
def reset_process!
|
|
404
|
+
@process = nil
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
# Instance stop method. Must be called on Jettywrapper.instance
|
|
408
|
+
# You're probably better off using Jettywrapper.stop(:jetty_home => "/path/to/jetty")
|
|
409
|
+
# @example
|
|
410
|
+
# Jettywrapper.configure(params)
|
|
411
|
+
# Jettywrapper.instance.stop
|
|
412
|
+
# return Jettywrapper.instance
|
|
413
|
+
def stop
|
|
414
|
+
logger.debug "Instance stop method called for pid '#{pid}'"
|
|
415
|
+
if pid
|
|
416
|
+
if @process
|
|
417
|
+
@process.stop
|
|
418
|
+
else
|
|
419
|
+
Process.kill("KILL", pid) rescue nil
|
|
420
|
+
end
|
|
413
421
|
|
|
414
|
-
# The file where the process ID will be written
|
|
415
|
-
def pid_file
|
|
416
|
-
jetty_home_to_pid_file(@jetty_home)
|
|
417
|
-
end
|
|
418
|
-
|
|
419
|
-
# Take the @jetty_home value and transform it into a legal filename
|
|
420
|
-
# @return [String] the name of the pid_file
|
|
421
|
-
# @example
|
|
422
|
-
# /usr/local/jetty1 => _usr_local_jetty1.pid
|
|
423
|
-
def jetty_home_to_pid_file(jetty_home)
|
|
424
422
|
begin
|
|
425
|
-
|
|
423
|
+
File.delete(pid_path)
|
|
426
424
|
rescue
|
|
427
|
-
raise "Couldn't make a pid file for jetty_home value #{jetty_home}"
|
|
428
|
-
raise $!
|
|
429
425
|
end
|
|
430
426
|
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
# The fully qualified path to the pid_file
|
|
431
|
+
def pid_path
|
|
432
|
+
#need to memoize this, becasuse the base path could be relative and the cwd can change in the yield block of wrap
|
|
433
|
+
@path ||= File.join(pid_dir, pid_file)
|
|
434
|
+
end
|
|
431
435
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
+
# The file where the process ID will be written
|
|
437
|
+
def pid_file
|
|
438
|
+
jetty_home_to_pid_file(@jetty_home)
|
|
439
|
+
end
|
|
436
440
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
441
|
+
# Take the @jetty_home value and transform it into a legal filename
|
|
442
|
+
# @return [String] the name of the pid_file
|
|
443
|
+
# @example
|
|
444
|
+
# /usr/local/jetty1 => _usr_local_jetty1.pid
|
|
445
|
+
def jetty_home_to_pid_file(jetty_home)
|
|
446
|
+
begin
|
|
447
|
+
jetty_home.gsub(/\//,'_') << "_#{self.class.env}" << ".pid"
|
|
448
|
+
rescue Exception => e
|
|
449
|
+
raise "Couldn't make a pid file for jetty_home value #{jetty_home}\n Caused by: #{e}"
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# The directory where the pid_file will be written
|
|
454
|
+
def pid_dir
|
|
455
|
+
File.expand_path(File.join(base_path,'tmp','pids'))
|
|
456
|
+
end
|
|
448
457
|
|
|
458
|
+
# Check to see if there is a pid file already
|
|
459
|
+
# @return true if the file exists, otherwise false
|
|
460
|
+
def pid_file?
|
|
461
|
+
File.exist?(pid_path)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
# the process id of the currently running jetty instance
|
|
465
|
+
def pid
|
|
466
|
+
File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
|
|
467
|
+
end
|
|
449
468
|
end
|
data/lib/tasks/jettywrapper.rake
CHANGED
|
@@ -15,7 +15,7 @@ module Hydra
|
|
|
15
15
|
it "starts" do
|
|
16
16
|
jetty_params = {
|
|
17
17
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
18
|
-
:startup_wait =>
|
|
18
|
+
:startup_wait => 90,
|
|
19
19
|
:java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
|
|
20
20
|
:jetty_port => TEST_JETTY_PORTS.first
|
|
21
21
|
}
|
|
@@ -39,7 +39,7 @@ module Hydra
|
|
|
39
39
|
it "won't start if it's already running" do
|
|
40
40
|
jetty_params = {
|
|
41
41
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
42
|
-
:startup_wait =>
|
|
42
|
+
:startup_wait => 90,
|
|
43
43
|
:java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
|
|
44
44
|
:jetty_port => TEST_JETTY_PORTS.first
|
|
45
45
|
}
|
|
@@ -18,10 +18,14 @@ require 'rubygems'
|
|
|
18
18
|
Jettywrapper.logger.level=3
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
before do
|
|
22
|
+
Jettywrapper.reset_config
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
context "downloading" do
|
|
22
26
|
context "with default file" do
|
|
23
27
|
it "should download the zip file" do
|
|
24
|
-
Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/
|
|
28
|
+
Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip -o tmp/v7.0.0.zip').and_return(system ('true'))
|
|
25
29
|
Jettywrapper.download
|
|
26
30
|
end
|
|
27
31
|
end
|
|
@@ -33,6 +37,13 @@ require 'rubygems'
|
|
|
33
37
|
Jettywrapper.url.should == 'http://example.co/file.zip'
|
|
34
38
|
end
|
|
35
39
|
end
|
|
40
|
+
context "specifying the version" do
|
|
41
|
+
it "should download the zip file" do
|
|
42
|
+
Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v9.9.9.zip -o tmp/v9.9.9.zip').and_return(system ('true'))
|
|
43
|
+
Jettywrapper.hydra_jetty_version = 'v9.9.9'
|
|
44
|
+
Jettywrapper.download
|
|
45
|
+
end
|
|
46
|
+
end
|
|
36
47
|
end
|
|
37
48
|
|
|
38
49
|
context "unzip" do
|
|
@@ -42,9 +53,10 @@ require 'rubygems'
|
|
|
42
53
|
context "with default file" do
|
|
43
54
|
it "should download the zip file" do
|
|
44
55
|
File.should_receive(:exists?).and_return(true)
|
|
45
|
-
Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-
|
|
46
|
-
Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/
|
|
47
|
-
Jettywrapper.should_receive(:system).with('
|
|
56
|
+
Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-v7.0.0')
|
|
57
|
+
Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/v7.0.0.zip').and_return(system ('true'))
|
|
58
|
+
Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
|
|
59
|
+
Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-v7.0.0 jetty').and_return(system ('true'))
|
|
48
60
|
Jettywrapper.unzip
|
|
49
61
|
end
|
|
50
62
|
end
|
|
@@ -57,6 +69,7 @@ require 'rubygems'
|
|
|
57
69
|
File.should_receive(:exists?).and_return(true)
|
|
58
70
|
Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
|
|
59
71
|
Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/file.zip').and_return(system ('true'))
|
|
72
|
+
Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
|
|
60
73
|
Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/interal_dir jetty').and_return(system ('true'))
|
|
61
74
|
Jettywrapper.unzip
|
|
62
75
|
end
|
|
@@ -84,7 +97,7 @@ require 'rubygems'
|
|
|
84
97
|
its(:url) {should == 'http://example.com/bar.zip'}
|
|
85
98
|
end
|
|
86
99
|
context "when url is not set" do
|
|
87
|
-
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/
|
|
100
|
+
its(:url) {should == 'https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip'}
|
|
88
101
|
end
|
|
89
102
|
end
|
|
90
103
|
|
|
@@ -105,11 +118,26 @@ require 'rubygems'
|
|
|
105
118
|
|
|
106
119
|
end
|
|
107
120
|
|
|
121
|
+
context ".jetty_dir" do
|
|
122
|
+
subject {Jettywrapper}
|
|
123
|
+
context "when a dir is set" do
|
|
124
|
+
before do
|
|
125
|
+
subject.jetty_dir = '/opt/jetty'
|
|
126
|
+
end
|
|
127
|
+
its(:jetty_dir) {should == '/opt/jetty'}
|
|
128
|
+
end
|
|
129
|
+
context "when dir is not set" do
|
|
130
|
+
before do
|
|
131
|
+
subject.jetty_dir = nil
|
|
132
|
+
end
|
|
133
|
+
its(:jetty_dir) {should == 'jetty'}
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
108
137
|
context "app_root" do
|
|
109
138
|
subject {Jettywrapper}
|
|
110
139
|
context "When rails is present" do
|
|
111
140
|
before do
|
|
112
|
-
Jettywrapper.reset_config
|
|
113
141
|
class Rails
|
|
114
142
|
def self.root
|
|
115
143
|
'rails_root'
|
|
@@ -118,7 +146,6 @@ require 'rubygems'
|
|
|
118
146
|
end
|
|
119
147
|
after do
|
|
120
148
|
Object.send(:remove_const, :Rails)
|
|
121
|
-
Jettywrapper.reset_config
|
|
122
149
|
end
|
|
123
150
|
its(:app_root) {should == 'rails_root'}
|
|
124
151
|
end
|
|
@@ -128,7 +155,6 @@ require 'rubygems'
|
|
|
128
155
|
end
|
|
129
156
|
after do
|
|
130
157
|
Object.send(:remove_const, :APP_ROOT)
|
|
131
|
-
Jettywrapper.reset_config
|
|
132
158
|
end
|
|
133
159
|
its(:app_root) {should == 'custom_root'}
|
|
134
160
|
end
|
|
@@ -136,8 +162,51 @@ require 'rubygems'
|
|
|
136
162
|
its(:app_root) {should == '.'}
|
|
137
163
|
end
|
|
138
164
|
end
|
|
165
|
+
|
|
166
|
+
describe "env" do
|
|
167
|
+
before do
|
|
168
|
+
ENV.delete('JETTYWRAPPER_ENV')
|
|
169
|
+
ENV.delete('RAILS_ENV')
|
|
170
|
+
ENV.delete('environment')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "should have a setter" do
|
|
174
|
+
Jettywrapper.env = "abc"
|
|
175
|
+
expect(Jettywrapper.env).to eq "abc"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "should load the ENV['JETTYWRAPPER_ENV']" do
|
|
179
|
+
ENV['JETTYWRAPPER_ENV'] = 'test'
|
|
180
|
+
ENV['RAILS_ENV'] = 'test2'
|
|
181
|
+
ENV['environment'] = 'test3'
|
|
182
|
+
expect(Jettywrapper.env).to eq "test"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "should be the Rails environment" do
|
|
186
|
+
Rails = double(env: 'test')
|
|
187
|
+
expect(Jettywrapper.env).to eq "test"
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should use the ENV['RAILS_ENV']" do
|
|
191
|
+
ENV['RAILS_ENV'] = 'test2'
|
|
192
|
+
ENV['environment'] = 'test3'
|
|
193
|
+
expect(Jettywrapper.env).to eq "test2"
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "should load the ENV['environment']" do
|
|
197
|
+
ENV['environment'] = 'test3'
|
|
198
|
+
expect(Jettywrapper.env).to eq "test3"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it "should default to 'development'" do
|
|
202
|
+
expect(Jettywrapper.env).to eq "development"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
end
|
|
139
206
|
|
|
140
207
|
context "config" do
|
|
208
|
+
before do
|
|
209
|
+
end
|
|
141
210
|
it "loads the application jetty.yml first" do
|
|
142
211
|
IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n")
|
|
143
212
|
config = Jettywrapper.load_config
|
|
@@ -162,6 +231,13 @@ require 'rubygems'
|
|
|
162
231
|
config[:a].should == 2
|
|
163
232
|
end
|
|
164
233
|
|
|
234
|
+
it "should take the env as an argument to load_config and the env should be sticky" do
|
|
235
|
+
IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\nfoo:\n a: 2")
|
|
236
|
+
config = Jettywrapper.load_config('foo')
|
|
237
|
+
config[:a].should == 2
|
|
238
|
+
expect(Jettywrapper.env).to eq 'foo'
|
|
239
|
+
end
|
|
240
|
+
|
|
165
241
|
it "falls back on a 'default' environment configuration" do
|
|
166
242
|
ENV['environment'] = 'test'
|
|
167
243
|
IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1")
|
|
@@ -186,11 +262,6 @@ require 'rubygems'
|
|
|
186
262
|
ts.jetty_opts.should == @jetty_params[:jetty_opts]
|
|
187
263
|
end
|
|
188
264
|
|
|
189
|
-
# passing in a hash is no longer optional
|
|
190
|
-
it "raises an error when called without a :jetty_home value" do
|
|
191
|
-
lambda { ts = Jettywrapper.configure }.should raise_exception
|
|
192
|
-
end
|
|
193
|
-
|
|
194
265
|
it "should override nil params with defaults" do
|
|
195
266
|
jetty_params = {
|
|
196
267
|
:quiet => nil,
|
|
@@ -231,7 +302,7 @@ require 'rubygems'
|
|
|
231
302
|
:jetty_home => '/tmp'
|
|
232
303
|
}
|
|
233
304
|
ts = Jettywrapper.configure(jetty_params)
|
|
234
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
305
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>5454))
|
|
235
306
|
ts.stop
|
|
236
307
|
ts.start
|
|
237
308
|
ts.pid.should eql(5454)
|
|
@@ -244,19 +315,16 @@ require 'rubygems'
|
|
|
244
315
|
}
|
|
245
316
|
ts = Jettywrapper.configure(jetty_params)
|
|
246
317
|
ts.stop
|
|
247
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
318
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
|
|
248
319
|
swp = Jettywrapper.start(jetty_params)
|
|
249
320
|
swp.pid.should eql(2323)
|
|
250
|
-
swp.pid_file.should eql("
|
|
321
|
+
swp.pid_file.should eql("_tmp_test.pid")
|
|
251
322
|
swp.stop
|
|
252
323
|
end
|
|
253
324
|
|
|
254
|
-
it "checks to see if its pid files are stale"
|
|
255
|
-
|
|
256
|
-
# return true if it's running, otherwise return false
|
|
257
325
|
it "can get the status for a given jetty instance" do
|
|
258
326
|
# Don't actually start jetty, just fake it
|
|
259
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
327
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>12345))
|
|
260
328
|
|
|
261
329
|
jetty_params = {
|
|
262
330
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
|
|
@@ -270,7 +338,7 @@ require 'rubygems'
|
|
|
270
338
|
|
|
271
339
|
it "can get the pid for a given jetty instance" do
|
|
272
340
|
# Don't actually start jetty, just fake it
|
|
273
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
341
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>54321))
|
|
274
342
|
jetty_params = {
|
|
275
343
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
|
|
276
344
|
}
|
|
@@ -285,7 +353,7 @@ require 'rubygems'
|
|
|
285
353
|
jetty_params = {
|
|
286
354
|
:jetty_home => '/tmp', :jetty_port => 8777
|
|
287
355
|
}
|
|
288
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
356
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
|
|
289
357
|
swp = Jettywrapper.start(jetty_params)
|
|
290
358
|
(File.file? swp.pid_path).should eql(true)
|
|
291
359
|
|
|
@@ -293,9 +361,20 @@ require 'rubygems'
|
|
|
293
361
|
(File.file? swp.pid_path).should eql(false)
|
|
294
362
|
end
|
|
295
363
|
|
|
296
|
-
|
|
297
|
-
ts
|
|
298
|
-
|
|
364
|
+
describe "creates a pid file" do
|
|
365
|
+
let(:ts) { Jettywrapper.configure(@jetty_params) }
|
|
366
|
+
describe "when the environment isn't set" do
|
|
367
|
+
before { ENV['environment'] = nil }
|
|
368
|
+
it "should have the path and env in the name" do
|
|
369
|
+
ts.pid_file.should eql("_path_to_jetty_development.pid")
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
describe "when the environment is set" do
|
|
373
|
+
before { ENV['environment'] = 'test' }
|
|
374
|
+
it "should have the path and env in the name" do
|
|
375
|
+
ts.pid_file.should eql("_path_to_jetty_test.pid")
|
|
376
|
+
end
|
|
377
|
+
end
|
|
299
378
|
end
|
|
300
379
|
|
|
301
380
|
it "knows where its pid file should be written" do
|
|
@@ -308,7 +387,7 @@ require 'rubygems'
|
|
|
308
387
|
:jetty_home => '/tmp'
|
|
309
388
|
}
|
|
310
389
|
ts = Jettywrapper.configure(jetty_params)
|
|
311
|
-
Jettywrapper.any_instance.stub(:process).and_return(
|
|
390
|
+
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2222))
|
|
312
391
|
ts.stop
|
|
313
392
|
ts.pid_file?.should eql(false)
|
|
314
393
|
ts.start
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jettywrapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Beer
|
|
@@ -10,132 +10,118 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: logger
|
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
|
18
18
|
requirements:
|
|
19
|
-
- -
|
|
19
|
+
- - ">="
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
|
-
- -
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
version: '0'
|
|
29
|
-
- !ruby/object:Gem::Dependency
|
|
30
|
-
name: mediashelf-loggable
|
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
|
32
|
-
requirements:
|
|
33
|
-
- - '>='
|
|
34
|
-
- !ruby/object:Gem::Version
|
|
35
|
-
version: '0'
|
|
36
|
-
type: :runtime
|
|
37
|
-
prerelease: false
|
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
-
requirements:
|
|
40
|
-
- - '>='
|
|
26
|
+
- - ">="
|
|
41
27
|
- !ruby/object:Gem::Version
|
|
42
28
|
version: '0'
|
|
43
29
|
- !ruby/object:Gem::Dependency
|
|
44
30
|
name: childprocess
|
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
|
46
32
|
requirements:
|
|
47
|
-
- -
|
|
33
|
+
- - ">="
|
|
48
34
|
- !ruby/object:Gem::Version
|
|
49
35
|
version: '0'
|
|
50
36
|
type: :runtime
|
|
51
37
|
prerelease: false
|
|
52
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
39
|
requirements:
|
|
54
|
-
- -
|
|
40
|
+
- - ">="
|
|
55
41
|
- !ruby/object:Gem::Version
|
|
56
42
|
version: '0'
|
|
57
43
|
- !ruby/object:Gem::Dependency
|
|
58
44
|
name: i18n
|
|
59
45
|
requirement: !ruby/object:Gem::Requirement
|
|
60
46
|
requirements:
|
|
61
|
-
- -
|
|
47
|
+
- - ">="
|
|
62
48
|
- !ruby/object:Gem::Version
|
|
63
49
|
version: '0'
|
|
64
50
|
type: :runtime
|
|
65
51
|
prerelease: false
|
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
67
53
|
requirements:
|
|
68
|
-
- -
|
|
54
|
+
- - ">="
|
|
69
55
|
- !ruby/object:Gem::Version
|
|
70
56
|
version: '0'
|
|
71
57
|
- !ruby/object:Gem::Dependency
|
|
72
58
|
name: activesupport
|
|
73
59
|
requirement: !ruby/object:Gem::Requirement
|
|
74
60
|
requirements:
|
|
75
|
-
- -
|
|
61
|
+
- - ">="
|
|
76
62
|
- !ruby/object:Gem::Version
|
|
77
63
|
version: 3.0.0
|
|
78
64
|
type: :runtime
|
|
79
65
|
prerelease: false
|
|
80
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
81
67
|
requirements:
|
|
82
|
-
- -
|
|
68
|
+
- - ">="
|
|
83
69
|
- !ruby/object:Gem::Version
|
|
84
70
|
version: 3.0.0
|
|
85
71
|
- !ruby/object:Gem::Dependency
|
|
86
72
|
name: rspec
|
|
87
73
|
requirement: !ruby/object:Gem::Requirement
|
|
88
74
|
requirements:
|
|
89
|
-
- -
|
|
75
|
+
- - "~>"
|
|
90
76
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: '
|
|
77
|
+
version: '2.99'
|
|
92
78
|
type: :development
|
|
93
79
|
prerelease: false
|
|
94
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
95
81
|
requirements:
|
|
96
|
-
- -
|
|
82
|
+
- - "~>"
|
|
97
83
|
- !ruby/object:Gem::Version
|
|
98
|
-
version: '
|
|
84
|
+
version: '2.99'
|
|
99
85
|
- !ruby/object:Gem::Dependency
|
|
100
|
-
name:
|
|
86
|
+
name: rspec-its
|
|
101
87
|
requirement: !ruby/object:Gem::Requirement
|
|
102
88
|
requirements:
|
|
103
|
-
- -
|
|
89
|
+
- - ">="
|
|
104
90
|
- !ruby/object:Gem::Version
|
|
105
91
|
version: '0'
|
|
106
92
|
type: :development
|
|
107
93
|
prerelease: false
|
|
108
94
|
version_requirements: !ruby/object:Gem::Requirement
|
|
109
95
|
requirements:
|
|
110
|
-
- -
|
|
96
|
+
- - ">="
|
|
111
97
|
- !ruby/object:Gem::Version
|
|
112
98
|
version: '0'
|
|
113
99
|
- !ruby/object:Gem::Dependency
|
|
114
|
-
name:
|
|
100
|
+
name: rake
|
|
115
101
|
requirement: !ruby/object:Gem::Requirement
|
|
116
102
|
requirements:
|
|
117
|
-
- -
|
|
103
|
+
- - ">="
|
|
118
104
|
- !ruby/object:Gem::Version
|
|
119
105
|
version: '0'
|
|
120
106
|
type: :development
|
|
121
107
|
prerelease: false
|
|
122
108
|
version_requirements: !ruby/object:Gem::Requirement
|
|
123
109
|
requirements:
|
|
124
|
-
- -
|
|
110
|
+
- - ">="
|
|
125
111
|
- !ruby/object:Gem::Version
|
|
126
112
|
version: '0'
|
|
127
113
|
- !ruby/object:Gem::Dependency
|
|
128
|
-
name:
|
|
114
|
+
name: yard
|
|
129
115
|
requirement: !ruby/object:Gem::Requirement
|
|
130
116
|
requirements:
|
|
131
|
-
- -
|
|
117
|
+
- - ">="
|
|
132
118
|
- !ruby/object:Gem::Version
|
|
133
119
|
version: '0'
|
|
134
120
|
type: :development
|
|
135
121
|
prerelease: false
|
|
136
122
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
123
|
requirements:
|
|
138
|
-
- -
|
|
124
|
+
- - ">="
|
|
139
125
|
- !ruby/object:Gem::Version
|
|
140
126
|
version: '0'
|
|
141
127
|
description: Spin up a jetty instance (e.g., the one at https://github.com/projecthydra/hydra-jetty)
|
|
@@ -146,9 +132,11 @@ executables: []
|
|
|
146
132
|
extensions: []
|
|
147
133
|
extra_rdoc_files: []
|
|
148
134
|
files:
|
|
149
|
-
- .gitignore
|
|
150
|
-
- .gitmodules
|
|
151
|
-
- .
|
|
135
|
+
- ".gitignore"
|
|
136
|
+
- ".gitmodules"
|
|
137
|
+
- ".rspec"
|
|
138
|
+
- ".travis.yml"
|
|
139
|
+
- CONTRIBUTING.md
|
|
152
140
|
- Gemfile
|
|
153
141
|
- History.txt
|
|
154
142
|
- README.textile
|
|
@@ -172,17 +160,17 @@ require_paths:
|
|
|
172
160
|
- lib
|
|
173
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
162
|
requirements:
|
|
175
|
-
- -
|
|
163
|
+
- - ">="
|
|
176
164
|
- !ruby/object:Gem::Version
|
|
177
165
|
version: '0'
|
|
178
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
167
|
requirements:
|
|
180
|
-
- -
|
|
168
|
+
- - ">="
|
|
181
169
|
- !ruby/object:Gem::Version
|
|
182
170
|
version: 1.3.6
|
|
183
171
|
requirements: []
|
|
184
172
|
rubyforge_project:
|
|
185
|
-
rubygems_version: 2.
|
|
173
|
+
rubygems_version: 2.2.2
|
|
186
174
|
signing_key:
|
|
187
175
|
specification_version: 4
|
|
188
176
|
summary: Convenience tasks for working with jetty from within a ruby project.
|