111 lines
3.9 KiB
Ruby
111 lines
3.9 KiB
Ruby
class Uwsgi < Formula
|
|
desc "Full stack for building hosting services"
|
|
homepage "https://uwsgi-docs.readthedocs.io/en/latest/"
|
|
url "https://files.pythonhosted.org/packages/24/fd/93851e4a076719199868d4c918cc93a52742e68370188c1c570a6e42a54f/uwsgi-2.0.20.tar.gz"
|
|
sha256 "88ab9867d8973d8ae84719cf233b7dafc54326fcaec89683c3f9f77c002cdff9"
|
|
license "GPL-2.0-or-later"
|
|
revision 1
|
|
head "https://github.com/unbit/uwsgi.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "56616732f6b6076f009d65e3361887585dffa03629788949ac44e1c3799e5a63"
|
|
sha256 arm64_big_sur: "52f4f303c418ae10ddd567ff72b434454e6f9ace5edc38bb1160616aea81b2b3"
|
|
sha256 monterey: "b698236d01c855607cc95ac5d210ba47048098f398879f370d3efb1da8ae7b4e"
|
|
sha256 big_sur: "272d281f40360c2455a96611a709a7dd892209e2aa3d8c0bd51be880f04f8628"
|
|
sha256 catalina: "7734363aedfd421c78d7d2c49dfab153c435e2d00334036d8228bacac1577b0a"
|
|
sha256 x86_64_linux: "4af33f405f0444ec27e682381d30b8f6ea68b3ea9080f89dbb8dee8000faec1a"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "openssl@1.1"
|
|
depends_on "pcre"
|
|
depends_on "python@3.10"
|
|
depends_on "yajl"
|
|
|
|
uses_from_macos "curl"
|
|
uses_from_macos "libxcrypt"
|
|
uses_from_macos "libxml2"
|
|
uses_from_macos "openldap"
|
|
uses_from_macos "perl"
|
|
|
|
on_linux do
|
|
depends_on "linux-pam"
|
|
end
|
|
|
|
def install
|
|
openssl = Formula["openssl@1.1"]
|
|
ENV.prepend "CFLAGS", "-I#{openssl.opt_include}"
|
|
ENV.prepend "LDFLAGS", "-L#{openssl.opt_lib}"
|
|
|
|
(buildpath/"buildconf/brew.ini").write <<~EOS
|
|
[uwsgi]
|
|
ssl = true
|
|
json = yajl
|
|
xml = libxml2
|
|
yaml = embedded
|
|
inherit = base
|
|
plugin_dir = #{libexec}/uwsgi
|
|
embedded_plugins = null
|
|
EOS
|
|
|
|
system "python3", "uwsgiconfig.py", "--verbose", "--build", "brew"
|
|
|
|
plugins = %w[airbrake alarm_curl asyncio cache
|
|
carbon cgi cheaper_backlog2 cheaper_busyness
|
|
corerouter curl_cron dumbloop dummy
|
|
echo emperor_amqp fastrouter forkptyrouter gevent
|
|
http logcrypto logfile ldap logpipe logsocket
|
|
msgpack notfound pam ping psgi pty rawrouter
|
|
router_basicauth router_cache router_expires
|
|
router_hash router_http router_memcached
|
|
router_metrics router_radius router_redirect
|
|
router_redis router_rewrite router_static
|
|
router_uwsgi router_xmldir rpc signal spooler
|
|
sqlite3 sslrouter stats_pusher_file
|
|
stats_pusher_socket symcall syslog
|
|
transformation_chunked transformation_gzip
|
|
transformation_offload transformation_tofile
|
|
transformation_toupper ugreen webdav zergpool]
|
|
plugins << "alarm_speech" if OS.mac?
|
|
plugins << "cplusplus" if OS.linux?
|
|
|
|
(libexec/"uwsgi").mkpath
|
|
plugins.each do |plugin|
|
|
system "python3", "uwsgiconfig.py", "--verbose", "--plugin", "plugins/#{plugin}", "brew"
|
|
end
|
|
|
|
system "python3", "uwsgiconfig.py", "--verbose", "--plugin", "plugins/python", "brew", "python3"
|
|
|
|
bin.install "uwsgi"
|
|
end
|
|
|
|
service do
|
|
run [opt_bin/"uwsgi", "--uid", "_www", "--gid", "_www", "--master", "--die-on-term", "--autoload", "--logto",
|
|
HOMEBREW_PREFIX/"var/log/uwsgi.log", "--emperor", HOMEBREW_PREFIX/"etc/uwsgi/apps-enabled"]
|
|
keep_alive true
|
|
working_dir HOMEBREW_PREFIX
|
|
end
|
|
|
|
test do
|
|
(testpath/"helloworld.py").write <<~EOS
|
|
def application(env, start_response):
|
|
start_response('200 OK', [('Content-Type','text/html')])
|
|
return [b"Hello World"]
|
|
EOS
|
|
|
|
port = free_port
|
|
|
|
pid = fork do
|
|
exec "#{bin}/uwsgi --http-socket 127.0.0.1:#{port} --protocol=http --plugin python3 -w helloworld"
|
|
end
|
|
sleep 2
|
|
|
|
begin
|
|
assert_match "Hello World", shell_output("curl localhost:#{port}")
|
|
ensure
|
|
Process.kill("SIGINT", pid)
|
|
Process.wait(pid)
|
|
end
|
|
end
|
|
end
|