-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
solr.rb
58 lines (47 loc) 路 2.05 KB
/
solr.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Solr < Formula
desc "Enterprise search platform from the Apache Lucene project"
homepage "https://solr.apache.org/"
url "https://dlcdn.apache.org/solr/solr/9.6.0/solr-9.6.0.tgz"
mirror "https://archive.apache.org/dist/solr/solr/9.6.0/solr-9.6.0.tgz"
sha256 "39ec04e45bb0a911cee6e4355a416e0ee25e1cc39f5316a3a654985a85a8ed32"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, all: "117420e444d0e7cc9f25bc7dbfc1660c6b2f371c6709523487d0ca5af9d1119f"
end
depends_on "openjdk"
def install
pkgshare.install "bin/solr.in.sh"
(var/"lib/solr").install "server/solr/README.md", "server/solr/solr.xml", "server/solr/zoo.cfg"
prefix.install "licenses", "modules", "server"
bin.install "bin/solr", "bin/post"
env = Language::Java.overridable_java_home_env
env["SOLR_HOME"] = "${SOLR_HOME:-#{var}/lib/solr}"
env["SOLR_LOGS_DIR"] = "${SOLR_LOGS_DIR:-#{var}/log/solr}"
env["SOLR_PID_DIR"] = "${SOLR_PID_DIR:-#{var}/run/solr}"
bin.env_script_all_files libexec, env
inreplace libexec/"solr", "/usr/local/share/solr", pkgshare
end
def post_install
(var/"run/solr").mkpath
(var/"log/solr").mkpath
end
service do
run [opt_bin/"solr", "start", "-f", "-s", HOMEBREW_PREFIX/"var/lib/solr"]
working_dir HOMEBREW_PREFIX
end
test do
ENV["SOLR_PID_DIR"] = testpath
port = free_port
assert_match "No Solr nodes are running", shell_output("#{bin}/solr status")
# Start a Solr node => exit code 0
shell_output("#{bin}/solr start -p #{port} -Djava.io.tmpdir=/tmp")
assert_match "Found 1 Solr nodes", shell_output("#{bin}/solr status")
# Impossible to start a second Solr node on the same port => exit code 1
shell_output("#{bin}/solr start -p #{port}", 1)
# Stop a Solr node => exit code 0
# Exit code is 1 without init process in a docker container
shell_output("#{bin}/solr stop -p #{port}", (OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]) ? 1 : 0)
# No Solr node left to stop => exit code 1
shell_output("#{bin}/solr stop -p #{port}", 1)
end
end