103 lines
3.3 KiB
Ruby
103 lines
3.3 KiB
Ruby
class Prestodb < Formula
|
|
include Language::Python::Shebang
|
|
|
|
desc "Distributed SQL query engine for big data"
|
|
homepage "https://prestodb.io"
|
|
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-server/0.269/presto-server-0.269.tar.gz"
|
|
sha256 "1f9a6cb557d4daa30a7f767170717308518b9594972e8f69ab38e7c0c5e59f5e"
|
|
license "Apache-2.0"
|
|
revision 1
|
|
|
|
# Upstream has said that we should check Maven for Presto version information
|
|
# and the highest version found there is newest:
|
|
# https://github.com/prestodb/presto/issues/16200
|
|
livecheck do
|
|
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-server/"
|
|
regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "3179627564c0a0e9b938cf84c55e2d0d2288bb8e266a302b9e9722c113b1acf8"
|
|
end
|
|
|
|
depends_on "openjdk"
|
|
depends_on "python@3.10"
|
|
|
|
resource "presto-cli" do
|
|
url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-cli/0.269/presto-cli-0.269-executable.jar"
|
|
sha256 "dffba4a2887b604700b7f74083d4c037f669e4dd221d05de28fe508ea3e5197e"
|
|
end
|
|
|
|
def install
|
|
libexec.install Dir["*"]
|
|
|
|
(libexec/"etc/node.properties").write <<~EOS
|
|
node.environment=production
|
|
node.id=ffffffff-ffff-ffff-ffff-ffffffffffff
|
|
node.data-dir=#{var}/presto/data
|
|
EOS
|
|
|
|
(libexec/"etc/jvm.config").write <<~EOS
|
|
-server
|
|
-Xmx16G
|
|
-XX:+UseG1GC
|
|
-XX:G1HeapRegionSize=32M
|
|
-XX:+UseGCOverheadLimit
|
|
-XX:+ExplicitGCInvokesConcurrent
|
|
-XX:+HeapDumpOnOutOfMemoryError
|
|
-XX:+ExitOnOutOfMemoryError
|
|
-Djdk.attach.allowAttachSelf=true
|
|
EOS
|
|
|
|
(libexec/"etc/config.properties").write <<~EOS
|
|
coordinator=true
|
|
node-scheduler.include-coordinator=true
|
|
http-server.http.port=8080
|
|
query.max-memory=5GB
|
|
query.max-memory-per-node=1GB
|
|
discovery-server.enabled=true
|
|
discovery.uri=http://localhost:8080
|
|
EOS
|
|
|
|
(libexec/"etc/log.properties").write "com.facebook.presto=INFO"
|
|
|
|
(libexec/"etc/catalog/jmx.properties").write "connector.name=jmx"
|
|
|
|
rewrite_shebang detected_python_shebang, libexec/"bin/launcher.py"
|
|
(bin/"presto-server").write_env_script libexec/"bin/launcher", Language::Java.overridable_java_home_env
|
|
|
|
resource("presto-cli").stage do
|
|
libexec.install "presto-cli-#{version}-executable.jar"
|
|
bin.write_jar_script libexec/"presto-cli-#{version}-executable.jar", "presto"
|
|
end
|
|
|
|
# Remove incompatible pre-built binaries
|
|
libprocname_dirs = libexec.glob("bin/procname/*")
|
|
# Keep the Linux-x86_64 directory to make bottles identical
|
|
libprocname_dirs.reject! { |dir| dir.basename.to_s == "Linux-x86_64" }
|
|
libprocname_dirs.reject! { |dir| dir.basename.to_s == "#{OS.kernel_name}-#{Hardware::CPU.arch}" }
|
|
libprocname_dirs.map(&:rmtree)
|
|
end
|
|
|
|
def post_install
|
|
(var/"presto/data").mkpath
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Add connectors to #{opt_libexec}/etc/catalog/. See:
|
|
https://prestodb.io/docs/current/connector.html
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run [opt_bin/"presto-server", "run"]
|
|
working_dir opt_libexec
|
|
end
|
|
|
|
test do
|
|
system bin/"presto-server", "run", "--help"
|
|
assert_match "Presto CLI #{version}", shell_output("#{bin}/presto --version").chomp
|
|
end
|
|
end
|