homebrew-core/Formula/supervisor.rb
2019-10-20 02:14:54 -04:00

88 lines
2.6 KiB
Ruby

class Supervisor < Formula
include Language::Python::Virtualenv
desc "Process Control System"
homepage "http://supervisord.org/"
url "https://github.com/Supervisor/supervisor/archive/4.1.0.tar.gz"
sha256 "e4e87a309d34c1356b77d1dfd300191b2a7c314e050d7b3853e5b91ef166c2f2"
bottle do
cellar :any_skip_relocation
sha256 "e4036a376329fdfe172d0884353e8726063b9535ff79a76f46e04369e680b5ba" => :catalina
sha256 "3e51e9866e4793367df67e0e566cb33a8f018a899cfbb36654f1d8baa9be4bd4" => :mojave
sha256 "41fd027c40c5e5da953fc007999db6248046f45ea68e9b1c5a4525834e98f130" => :high_sierra
end
depends_on "python"
def install
inreplace buildpath/"supervisor/skel/sample.conf" do |s|
s.gsub! %r{/tmp/supervisor\.sock}, var/"run/supervisor.sock"
s.gsub! %r{/tmp/supervisord\.log}, var/"log/supervisord.log"
s.gsub! %r{/tmp/supervisord\.pid}, var/"run/supervisord.pid"
s.gsub! /^;\[include\]$/, "[include]"
s.gsub! %r{^;files = relative/directory/\*\.ini$}, "files = #{etc}/supervisor.d/*.ini"
end
virtualenv_install_with_resources
etc.install buildpath/"supervisor/skel/sample.conf" => "supervisord.ini"
end
def post_install
(var/"run").mkpath
(var/"log").mkpath
end
plist_options :manual => "supervisord -c #{HOMEBREW_PREFIX}/etc/supervisord.ini"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/supervisord</string>
<string>-c</string>
<string>#{etc}/supervisord.ini</string>
<string>--nodaemon</string>
</array>
</dict>
</plist>
EOS
end
test do
(testpath/"sd.ini").write <<~EOS
[unix_http_server]
file=supervisor.sock
[supervisord]
loglevel=debug
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix://supervisor.sock
EOS
begin
pid = fork { exec bin/"supervisord", "--nodaemon", "-c", "sd.ini" }
sleep 1
output = shell_output("#{bin}/supervisorctl -c sd.ini version")
assert_match version.to_s, output
ensure
Process.kill "TERM", pid
end
end
end