89 lines
3.0 KiB
Ruby
89 lines
3.0 KiB
Ruby
class Rabbitmq < Formula
|
|
desc "Messaging broker"
|
|
homepage "https://www.rabbitmq.com"
|
|
url "https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.6/rabbitmq-server-generic-unix-3.9.6.tar.xz"
|
|
sha256 "74782a422ee0f94565859ff47d69a70bb824d4a9dffc2be64b11123cbb5b5a4f"
|
|
license "MPL-2.0"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "5f3556c86064c616ca12b019302d4c337ff1d867a97becc6b60b482020c27758"
|
|
end
|
|
|
|
depends_on "python@3.9" => :build
|
|
depends_on "erlang"
|
|
|
|
def install
|
|
# Install the base files
|
|
prefix.install Dir["*"]
|
|
|
|
# Setup the lib files
|
|
(var/"lib/rabbitmq").mkpath
|
|
(var/"log/rabbitmq").mkpath
|
|
|
|
# Correct SYS_PREFIX for things like rabbitmq-plugins
|
|
erlang = Formula["erlang"]
|
|
inreplace sbin/"rabbitmq-defaults" do |s|
|
|
s.gsub! "SYS_PREFIX=${RABBITMQ_HOME}", "SYS_PREFIX=#{HOMEBREW_PREFIX}"
|
|
s.gsub! "CLEAN_BOOT_FILE=start_clean", "CLEAN_BOOT_FILE=#{erlang.opt_lib/"erlang/bin/start_clean"}"
|
|
s.gsub! "SASL_BOOT_FILE=start_sasl", "SASL_BOOT_FILE=#{erlang.opt_lib/"erlang/bin/start_clean"}"
|
|
end
|
|
|
|
# Set RABBITMQ_HOME in rabbitmq-env
|
|
inreplace sbin/"rabbitmq-env",
|
|
'RABBITMQ_HOME="$(rmq_realpath "${RABBITMQ_SCRIPTS_DIR}/..")"',
|
|
"RABBITMQ_HOME=#{prefix}"
|
|
|
|
# Create the rabbitmq-env.conf file
|
|
rabbitmq_env_conf = etc/"rabbitmq/rabbitmq-env.conf"
|
|
rabbitmq_env_conf.write rabbitmq_env unless rabbitmq_env_conf.exist?
|
|
|
|
# Enable plugins - management web UI; STOMP, MQTT, AMQP 1.0 protocols
|
|
enabled_plugins_path = etc/"rabbitmq/enabled_plugins"
|
|
unless enabled_plugins_path.exist?
|
|
enabled_plugins_path.write "[rabbitmq_management,rabbitmq_stomp,rabbitmq_amqp1_0," \
|
|
"rabbitmq_mqtt,rabbitmq_stream]."
|
|
end
|
|
|
|
sbin.install prefix/"plugins/rabbitmq_management-#{version}/priv/www/cli/rabbitmqadmin"
|
|
(sbin/"rabbitmqadmin").chmod 0755
|
|
(bash_completion/"rabbitmqadmin.bash").write Utils.safe_popen_read("#{sbin}/rabbitmqadmin", "--bash-completion")
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Management Plugin enabled by default at http://localhost:15672
|
|
EOS
|
|
end
|
|
|
|
def rabbitmq_env
|
|
<<~EOS
|
|
CONFIG_FILE=#{etc}/rabbitmq/rabbitmq
|
|
NODE_IP_ADDRESS=127.0.0.1
|
|
NODENAME=rabbit@localhost
|
|
RABBITMQ_LOG_BASE=#{var}/log/rabbitmq
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run opt_sbin/"rabbitmq-server"
|
|
log_path var/"log/rabbitmq/std_out.log"
|
|
error_log_path var/"log/rabbitmq/std_error.log"
|
|
# need erl in PATH
|
|
environment_variables PATH: "#{HOMEBREW_PREFIX}/sbin:/usr/sbin:/usr/bin:/bin:#{HOMEBREW_PREFIX}/bin",
|
|
CONF_ENV_FILE: etc/"rabbitmq/rabbitmq-env.conf"
|
|
end
|
|
|
|
test do
|
|
ENV["RABBITMQ_MNESIA_BASE"] = testpath/"var/lib/rabbitmq/mnesia"
|
|
pid = fork { exec sbin/"rabbitmq-server" }
|
|
system sbin/"rabbitmq-diagnostics", "wait", "--pid", pid
|
|
system sbin/"rabbitmqctl", "status"
|
|
system sbin/"rabbitmqctl", "stop"
|
|
end
|
|
end
|