solr_wrapper 0.0.3 → 0.0.4
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/lib/solr_wrapper/instance.rb +33 -8
- data/lib/solr_wrapper/version.rb +1 -1
- data/spec/lib/solr_wrapper_spec.rb +5 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afbb108d004d57c73e68e21e9c4352d0249ec561
|
4
|
+
data.tar.gz: 3d11fa951e19ff35da4e686b047eafb270f2288a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd9cbb7c32124dd36dd4f49e33a8f6248b42851022cc7981125dedb92334c1930570d9efe58d4a2b8327defa0359e0cdd1106f5cd11e14d7be1b8a09b835bd5a
|
7
|
+
data.tar.gz: dfff06a0df7ee5a7f550b6bbb0e956256d772624dcdae694865899394da99ae7c38038e7c2308d9e863fbc3081177725ce1c92857210dc121cd7f68e78ae7dcc
|
@@ -31,13 +31,17 @@ module SolrWrapper
|
|
31
31
|
else
|
32
32
|
IO.copy_stream(io, stringio)
|
33
33
|
end
|
34
|
-
_,
|
35
|
-
if
|
34
|
+
_, exit_status = Process.wait2(io.pid)
|
35
|
+
if exit_status != 0
|
36
36
|
stringio.rewind
|
37
37
|
raise "Unable to start solr: #{stringio.read}"
|
38
38
|
end
|
39
39
|
end if managed?
|
40
40
|
|
41
|
+
# Wait for solr to start
|
42
|
+
unless status
|
43
|
+
sleep 1
|
44
|
+
end
|
41
45
|
started!
|
42
46
|
end
|
43
47
|
|
@@ -51,12 +55,17 @@ module SolrWrapper
|
|
51
55
|
else
|
52
56
|
IO.copy_stream(io, stringio)
|
53
57
|
end
|
54
|
-
_,
|
58
|
+
_, exit_status = Process.wait2(io.pid)
|
55
59
|
|
56
|
-
if
|
60
|
+
if exit_status != 0
|
57
61
|
stringio.rewind
|
58
62
|
raise "Unable to start solr: #{stringio.read}"
|
59
63
|
end
|
64
|
+
|
65
|
+
# Wait for solr to stop
|
66
|
+
while status
|
67
|
+
sleep 1
|
68
|
+
end
|
60
69
|
end if managed?
|
61
70
|
end
|
62
71
|
|
@@ -68,17 +77,16 @@ module SolrWrapper
|
|
68
77
|
IO.popen([solr_binary, "status", "-p", port, err: [:child, :out]]) do |io|
|
69
78
|
IO.copy_stream(io, stringio)
|
70
79
|
|
71
|
-
_,
|
80
|
+
_, exit_status = Process.wait2(io.pid)
|
72
81
|
|
73
82
|
stringio.rewind
|
74
83
|
|
75
|
-
if
|
84
|
+
if exit_status != 0
|
76
85
|
raise "Unable to query solr status: #{stringio.read}"
|
77
86
|
end
|
78
87
|
end
|
79
88
|
|
80
89
|
out = stringio.read
|
81
|
-
|
82
90
|
out =~ /running on port #{port}/
|
83
91
|
end
|
84
92
|
|
@@ -87,6 +95,8 @@ module SolrWrapper
|
|
87
95
|
end
|
88
96
|
|
89
97
|
def extract
|
98
|
+
return solr_dir if File.exists?(solr_binary) and extracted_version == version
|
99
|
+
|
90
100
|
zip_path = download
|
91
101
|
|
92
102
|
begin
|
@@ -106,6 +116,7 @@ module SolrWrapper
|
|
106
116
|
begin
|
107
117
|
FileUtils.remove_dir(solr_dir,true)
|
108
118
|
FileUtils.cp_r File.join(tmp_save_dir, File.basename(default_url, ".zip")), solr_dir
|
119
|
+
self.extracted_version = version
|
109
120
|
FileUtils.chmod 0755, solr_binary
|
110
121
|
rescue Exception => e
|
111
122
|
abort "Unable to copy #{tmp_save_dir} to #{solr_dir}: #{e.message}"
|
@@ -113,7 +124,7 @@ module SolrWrapper
|
|
113
124
|
|
114
125
|
solr_dir
|
115
126
|
ensure
|
116
|
-
FileUtils.remove_entry tmp_save_dir
|
127
|
+
FileUtils.remove_entry tmp_save_dir if File.exists? tmp_save_dir
|
117
128
|
end
|
118
129
|
|
119
130
|
def download
|
@@ -249,5 +260,19 @@ module SolrWrapper
|
|
249
260
|
def managed?
|
250
261
|
!!options.fetch(:managed, true)
|
251
262
|
end
|
263
|
+
|
264
|
+
def version_file
|
265
|
+
options.fetch(:version_file, File.join(solr_dir, "VERSION"))
|
266
|
+
end
|
267
|
+
|
268
|
+
def extracted_version
|
269
|
+
File.read(version_file).strip if File.exists? version_file
|
270
|
+
end
|
271
|
+
|
272
|
+
def extracted_version= version
|
273
|
+
File.open(version_file, "w") do |f|
|
274
|
+
f.puts version
|
275
|
+
end
|
276
|
+
end
|
252
277
|
end
|
253
278
|
end
|
data/lib/solr_wrapper/version.rb
CHANGED
@@ -3,16 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe SolrWrapper do
|
4
4
|
describe ".wrap" do
|
5
5
|
it "should launch solr" do
|
6
|
-
SolrWrapper.wrap
|
7
|
-
expect
|
8
|
-
|
9
|
-
|
10
|
-
s.close
|
11
|
-
true
|
12
|
-
rescue
|
13
|
-
false
|
6
|
+
SolrWrapper.wrap do |solr|
|
7
|
+
expect {
|
8
|
+
Timeout::timeout(15) do
|
9
|
+
TCPSocket.new('127.0.0.1', solr.port).close
|
14
10
|
end
|
15
|
-
|
11
|
+
}.not_to raise_exception
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|