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.0.tar.gz" sha256 "48452951254ddbc8d0da1cf1db954bddcbab2a5abc8a35bf99ef247feef273d2" head "https://github.com/tidwall/tile38.git" bottle do cellar :any_skip_relocation sha256 "40527f80c283c6c709edc580722d90677b82a633dd2d47f237ef31da9a103c74" => :mojave sha256 "477168f7089ba4ee84a97f9db4a2785938cb24432a4e75127e42eba09c6374ba" => :high_sierra sha256 "6a6c693b0fa398859a46639d5afa1c47c0cf47e076f600016c3092ad85dd015a" => :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