91 lines
2.7 KiB
Ruby
91 lines
2.7 KiB
Ruby
class Pushpin < Formula
|
|
desc "Reverse proxy for realtime web services"
|
|
homepage "https://pushpin.org/"
|
|
url "https://dl.bintray.com/fanout/source/pushpin-1.20.3.tar.bz2"
|
|
sha256 "ceebe143b25aecb63bc7b059e23878472ed511d34f5e8e42542011e40195da5e"
|
|
head "https://github.com/fanout/pushpin.git"
|
|
|
|
bottle do
|
|
sha256 "b33cb10294c3051de9b29de7b592adb918144c12812315a123f5b6d44c042ca5" => :mojave
|
|
sha256 "929ac59230b93e4a23d200770c2c85965d614fbb0139d591469e68775d0f5b3a" => :high_sierra
|
|
sha256 "2ba1f159827f923344e965612273172563a6fe32357b3c4badbf2e4820b46be5" => :sierra
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "mongrel2"
|
|
depends_on "qt"
|
|
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", "check"
|
|
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 urllib2
|
|
import threading
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
|
class TestHandler(BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
self.send_response(200)
|
|
self.end_headers()
|
|
self.wfile.write('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()
|
|
f = urllib2.urlopen('http://localhost:7999/test')
|
|
body = f.read()
|
|
assert(body == 'test response\\n')
|
|
EOS
|
|
|
|
pid = fork do
|
|
exec "#{bin}/pushpin", "--config=#{conffile}"
|
|
end
|
|
|
|
begin
|
|
sleep 3 # make sure pushpin processes have started
|
|
system "python", runfile
|
|
ensure
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|