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.3.tar.gz" sha256 "5e7526e11740b452f2188b8f79ed87b1ba7d84cb624bc9486524e14cf7a71f9d" head "https://github.com/tidwall/tile38.git" bottle do cellar :any_skip_relocation sha256 "abcfe4352a1d8a4574a59122b1d4d9c00b6b9f23f2e55b529b5cb4e46cbe199c" => :mojave sha256 "4acb01fb2ca7499f03ce9aee8f5e29b63a5547a453a0be31f50bb2339b7f95bd" => :high_sierra sha256 "f17bc1d02f1eea722e0423b08eabc82abd9b119881adf19ef9f60ead44cd9777" => :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