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.16.1.tar.gz" sha256 "8ce1096b8a72dd56bb5f427ac5d4c02142ac72514676dde395f633bd4ed84a01" head "https://github.com/tidwall/tile38.git" bottle do cellar :any_skip_relocation sha256 "19509f895c9ab51652f3e5b587b9630ae8ecf94e9a78c6bc2d4c7ebb881fc624" => :mojave sha256 "67b516370936d7f7b42057e741bc1e7155a483b2141a3dfe3598fbf8fa6c3370" => :high_sierra sha256 "c16ec170f4ef9b3ab023358932313cfa63906803fd75884b656716ff0692ca4a" => :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