97 lines
2.8 KiB
Ruby
97 lines
2.8 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.2.0.tar.gz"
|
|
sha256 "05031f36ad15cad47fb56f01d8e075f952ae39ba8ce492ea790ebb310e3f0368"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "baf24c9b9b0ce2463148d676f1f985d090edde2b5393417cce8e4d9df93d3523" => :catalina
|
|
sha256 "8987e771d53dea6bee2955f83a1fd4255af39cca86bb02ae518bc1a7daca2f6b" => :mojave
|
|
sha256 "7a13e792368a2fbba5c426860206f7acf18b5625312f33a97d1cc97e9c5f71c4" => :high_sierra
|
|
end
|
|
|
|
depends_on "python@3.8"
|
|
|
|
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.conf"
|
|
end
|
|
|
|
def post_install
|
|
(var/"run").mkpath
|
|
(var/"log").mkpath
|
|
conf_warn = <<~EOS
|
|
The default location for supervisor's config file is now:
|
|
#{etc}/supervisord.conf
|
|
Please move your config file to this location and restart supervisor.
|
|
EOS
|
|
old_conf = etc/"supervisord.ini"
|
|
opoo conf_warn if old_conf.exist?
|
|
end
|
|
|
|
plist_options manual: "supervisord"
|
|
|
|
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.conf</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
|