class Tile38 < Formula desc "In-memory geolocation data store, spatial index, and realtime geofence" homepage "https://tile38.com/" url "https://github.com/tidwall/tile38/archive/1.17.5.tar.gz" sha256 "09930ff3d3aca95e27dbbd38aa8fd3505cb1065a9ba6ab0756207d4fbd7b711c" head "https://github.com/tidwall/tile38.git" bottle do cellar :any_skip_relocation sha256 "7fdadd0b53b2f45e55b3cc17f9d76ff64d5a09646dee1df7c393c59abec0c6cd" => :mojave sha256 "4a36f2aba9c1834cd85ac281a9f20edf909ac206f819b844251d728a1b762716" => :high_sierra sha256 "816d51599b6fe30b2b38b9e3436ae95f580c18a2abeaca034f777a0b822d9795" => :sierra end depends_on "go" => :build def datadir var/"tile38/data" end def install ENV["GOPATH"] = buildpath system "make" bin.install "tile38-cli", "tile38-server" end def post_install # Make sure the data directory exists datadir.mkpath end def caveats; <<~EOS To connect: tile38-cli EOS end plist_options :manual => "tile38-server -d #{HOMEBREW_PREFIX}/var/tile38/data" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/tile38-server -d #{datadir} RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/tile38.log StandardOutPath #{var}/log/tile38.log EOS end test do begin pid = fork do exec "#{bin}/tile38-server", "-q" end sleep 2 json_output = shell_output("#{bin}/tile38-cli server") tile38_server = JSON.parse(json_output) assert_equal tile38_server["ok"], true ensure Process.kill("HUP", pid) end end end