class Presto < Formula 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.179/presto-server-0.179.tar.gz" sha256 "a348b88541a77d4d76014ba3bfa525ece8c7d5a388c564131649ade419758f3d" bottle :unneeded depends_on :java => "1.8+" cli_version = version resource "presto-cli" do version cli_version url "https://search.maven.org/remotecontent?filepath=com/facebook/presto/presto-cli/#{version}/presto-cli-#{version}-executable.jar" sha256 "f9ac124ce2acae655df927e860016f6db333ec112d2ba3bf7b3e9bb93b057965" end def install libexec.install Dir["*"] (libexec/"etc/node.properties").write <<-EOS.undent node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=#{var}/presto/data EOS (libexec/"etc/jvm.config").write <<-EOS.undent -server -Xmx16G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError EOS (libexec/"etc/config.properties").write <<-EOS.undent 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" (bin/"presto-server").write <<-EOS.undent #!/bin/bash exec "#{libexec}/bin/launcher" "$@" EOS resource("presto-cli").stage do bin.install "presto-cli-#{version}-executable.jar" => "presto" end end def post_install (var/"presto/data").mkpath end def caveats; <<-EOS.undent Add connectors to #{libexec}/etc/catalog/. See: https://prestodb.io/docs/current/connector.html EOS end plist_options :manual => "presto-server run" def plist; <<-EOS.undent Label #{plist_name} RunAtLoad AbandonProcessGroup WorkingDirectory #{opt_libexec} ProgramArguments #{opt_bin}/presto-server run EOS end test do system bin/"presto-server", "run", "--help" assert_equal "Presto CLI #{version}", shell_output("#{bin}/presto --version").chomp end end