class Supervisor < Formula include Language::Python::Virtualenv desc "Process Control System" homepage "http://supervisord.org/" url "https://github.com/Supervisor/supervisor/archive/4.0.4.tar.gz" sha256 "5087a99c008c8b4ca26c27a360cbcef03430589b8f60912715179ef19e16fa18" bottle do cellar :any_skip_relocation sha256 "a2e538f406d031d64ac2c97747e645393376c28a9e06f71464d6cc9f3434caf8" => :catalina sha256 "7d53548c12b1ec06a6bbbd5f8cd8082bccd8c3c48364809c2970d67543f64f79" => :mojave sha256 "4e323805384ab0ccd6f3ef7d0e3c4329ae0f1edb9cd43d4ef45cbcec72b6a9fb" => :high_sierra sha256 "f9ed5aff67f1fd79b0ced09c5d85a546eb2451c1d621a704c624215f201e1650" => :sierra end depends_on "python" resource "meld3" do url "https://files.pythonhosted.org/packages/45/a0/317c6422b26c12fe0161e936fc35f36552069ba8e6f7ecbd99bbffe32a5f/meld3-1.0.2.tar.gz" sha256 "f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558" end 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 KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/supervisord -c #{etc}/supervisord.ini --nodaemon 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