95 lines
2.9 KiB
Ruby
95 lines
2.9 KiB
Ruby
class Pushpin < Formula
|
|
desc "Reverse proxy for realtime web services"
|
|
homepage "https://pushpin.org/"
|
|
url "https://github.com/fanout/pushpin/releases/download/v1.33.1/pushpin-1.33.1.tar.bz2"
|
|
sha256 "37b8ed8a262492e86fd02fe55c3b6f280cff2da718400ce926b5480745cec4a4"
|
|
license "AGPL-3.0-or-later"
|
|
head "https://github.com/fanout/pushpin.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 big_sur: "5d4b6f4f552d6e2ce51e7b69c460841b10544061291f01d7935457a4fe59514d"
|
|
sha256 catalina: "459df44b74ec23db384e8e6235de59e2a8c2e74bb4199c71fcbb391982a58c1e"
|
|
sha256 mojave: "ec5af70cb4c9164cb881fa0bc63ce8809b351b28db3188e8e17d578150f63beb"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "rust" => :build
|
|
depends_on "condure"
|
|
depends_on "mongrel2"
|
|
depends_on "python@3.9"
|
|
depends_on "qt@5"
|
|
depends_on "zeromq"
|
|
depends_on "zurl"
|
|
|
|
def install
|
|
system "./configure", "--prefix=#{prefix}",
|
|
"--configdir=#{etc}",
|
|
"--rundir=#{var}/run",
|
|
"--logdir=#{var}/log",
|
|
"--extraconf=QMAKE_MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
conffile = testpath/"pushpin.conf"
|
|
routesfile = testpath/"routes"
|
|
runfile = testpath/"test.py"
|
|
|
|
cp HOMEBREW_PREFIX/"etc/pushpin/pushpin.conf", conffile
|
|
|
|
inreplace conffile do |s|
|
|
s.gsub! "rundir=#{HOMEBREW_PREFIX}/var/run/pushpin", "rundir=#{testpath}/var/run/pushpin"
|
|
s.gsub! "logdir=#{HOMEBREW_PREFIX}/var/log/pushpin", "logdir=#{testpath}/var/log/pushpin"
|
|
end
|
|
|
|
routesfile.write <<~EOS
|
|
* localhost:10080
|
|
EOS
|
|
|
|
runfile.write <<~EOS
|
|
import threading
|
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
from urllib.request import urlopen
|
|
class TestHandler(BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
self.send_response(200)
|
|
self.end_headers()
|
|
self.wfile.write(b'test response\\n')
|
|
def server_worker(c):
|
|
global port
|
|
server = HTTPServer(('', 10080), TestHandler)
|
|
port = server.server_address[1]
|
|
c.acquire()
|
|
c.notify()
|
|
c.release()
|
|
try:
|
|
server.serve_forever()
|
|
except:
|
|
server.server_close()
|
|
c = threading.Condition()
|
|
c.acquire()
|
|
server_thread = threading.Thread(target=server_worker, args=(c,))
|
|
server_thread.daemon = True
|
|
server_thread.start()
|
|
c.wait()
|
|
c.release()
|
|
with urlopen('http://localhost:7999/test') as f:
|
|
body = f.read()
|
|
assert(body == b'test response\\n')
|
|
EOS
|
|
|
|
pid = fork do
|
|
exec "#{bin}/pushpin", "--config=#{conffile}"
|
|
end
|
|
|
|
begin
|
|
sleep 3 # make sure pushpin processes have started
|
|
system Formula["python@3.9"].opt_bin/"python3", runfile
|
|
ensure
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|