88 lines
2.6 KiB
Ruby
88 lines
2.6 KiB
Ruby
class Pushpin < Formula
|
|
desc "Reverse proxy for realtime web services"
|
|
homepage "http://pushpin.org"
|
|
url "https://dl.bintray.com/fanout/source/pushpin-1.13.1.tar.bz2"
|
|
sha256 "99422b64ea7414309d1e01325e56ec18be34d85539affd5560fd8842328e77bd"
|
|
|
|
head "https://github.com/fanout/pushpin.git"
|
|
|
|
bottle do
|
|
sha256 "e712906d5f6102ef8cb6d4608b83dd0bca828642f4d1fcb34c68ecfe87b0052c" => :sierra
|
|
sha256 "fa7580a36511384381cad49f5e7a49b1098550e2901a87bacabbc6ad784c207c" => :el_capitan
|
|
sha256 "359e9bbddecfb05658d997901c7c21e6b0e783b8c11e22d443a7aad371500c2a" => :yosemite
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "qt5"
|
|
depends_on "zeromq"
|
|
depends_on "mongrel2"
|
|
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.undent
|
|
* localhost:10080
|
|
EOS
|
|
|
|
runfile.write <<-EOS.undent
|
|
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
|