Change rabbitmq-server configuration files
The files rabbitmq-server.ocf, rabbitmq-server.service and rabbitmq-server.logrotate are currently being altered by rabbitmq-server-config on the config-files repo. This review includes a patch with the modified files. After this is merged, the rabbitmq-server-config package should be removed from the config-files repo. Test-Plan: Story: Task: Change-Id: Ie9d0539c0370858e67779a7390a73745db1a0247 Signed-off-by: mmachado <matheus.machadoguilhermino@windriver.com>
This commit is contained in:
parent
2b88224302
commit
088186cc67
|
@ -0,0 +1,323 @@
|
||||||
|
From 69c4358898a7ae26485b0ce05e7191d36ca59e1a Mon Sep 17 00:00:00 2001
|
||||||
|
From: mmachado <matheus.machadoguilhermino@windriver.com>
|
||||||
|
Date: Thu, 8 Feb 2024 11:15:05 -0300
|
||||||
|
Subject: [PATCH] Change rabbitmq-server configuration files
|
||||||
|
|
||||||
|
The files in this patch were previously implemented by the
|
||||||
|
rabbitmq-server-config package on the config file repo.
|
||||||
|
|
||||||
|
Signed-off-by: mmachado <matheus.machadoguilhermino@windriver.com>
|
||||||
|
---
|
||||||
|
debian/rabbitmq-server.logrotate | 16 ++--
|
||||||
|
debian/rabbitmq-server.service | 21 ++---
|
||||||
|
scripts/rabbitmq-server.ocf | 127 ++++++++++++++++++++++---------
|
||||||
|
3 files changed, 110 insertions(+), 54 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/debian/rabbitmq-server.logrotate b/debian/rabbitmq-server.logrotate
|
||||||
|
index c509b78..4c8f3b0 100644
|
||||||
|
--- a/debian/rabbitmq-server.logrotate
|
||||||
|
+++ b/debian/rabbitmq-server.logrotate
|
||||||
|
@@ -1,7 +1,13 @@
|
||||||
|
/var/log/rabbitmq/*.log {
|
||||||
|
- daily
|
||||||
|
- missingok
|
||||||
|
- compress
|
||||||
|
- delaycompress
|
||||||
|
- notifempty
|
||||||
|
+ weekly
|
||||||
|
+ missingok
|
||||||
|
+ rotate 20
|
||||||
|
+ compress
|
||||||
|
+ delaycompress
|
||||||
|
+ notifempty
|
||||||
|
+ sharedscripts
|
||||||
|
+ postrotate
|
||||||
|
+ pgrep beam.smp >/dev/null && /usr/sbin/rabbitmqctl -q rotate_logs
|
||||||
|
+ true
|
||||||
|
+ endscript
|
||||||
|
}
|
||||||
|
diff --git a/debian/rabbitmq-server.service b/debian/rabbitmq-server.service
|
||||||
|
index 8197ae7..92aa231 100644
|
||||||
|
--- a/debian/rabbitmq-server.service
|
||||||
|
+++ b/debian/rabbitmq-server.service
|
||||||
|
@@ -1,24 +1,17 @@
|
||||||
|
[Unit]
|
||||||
|
-Description=RabbitMQ Messaging Server
|
||||||
|
-After=network.target epmd@.socket
|
||||||
|
-Wants=network.target epmd@.socket
|
||||||
|
+Description=RabbitMQ broker
|
||||||
|
+After=network.target epmd@0.0.0.0.socket
|
||||||
|
+Wants=network.target epmd@0.0.0.0.socket
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
-User=rabbitmq
|
||||||
|
-Group=rabbitmq
|
||||||
|
-UMask=0027
|
||||||
|
+User=root
|
||||||
|
+Group=root
|
||||||
|
NotifyAccess=all
|
||||||
|
-TimeoutStartSec=600
|
||||||
|
-LimitNOFILE=65536
|
||||||
|
-SyslogIdentifier=rabbitmq
|
||||||
|
-Restart=on-failure
|
||||||
|
-RestartSec=10
|
||||||
|
+TimeoutStartSec=3600
|
||||||
|
WorkingDirectory=/var/lib/rabbitmq
|
||||||
|
ExecStart=/usr/lib/rabbitmq/bin/rabbitmq-server
|
||||||
|
-ExecStop=/usr/sbin/rabbitmqctl stop
|
||||||
|
-StandardOutput=append:/var/log/rabbitmq/rabbitmq-server.log
|
||||||
|
-StandardError=append:/var/log/rabbitmq/rabbitmq-server.error.log
|
||||||
|
+ExecStop=/usr/lib/rabbitmq/bin/rabbitmqctl stop
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
diff --git a/scripts/rabbitmq-server.ocf b/scripts/rabbitmq-server.ocf
|
||||||
|
index 7bf3fff..485bf6e 100755
|
||||||
|
--- a/scripts/rabbitmq-server.ocf
|
||||||
|
+++ b/scripts/rabbitmq-server.ocf
|
||||||
|
@@ -1,10 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
-
|
||||||
|
-## This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
-## License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
-## file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
+## The contents of this file are subject to the Mozilla Public License
|
||||||
|
+## Version 1.1 (the "License"); you may not use this file except in
|
||||||
|
+## compliance with the License. You may obtain a copy of the License
|
||||||
|
+## at http://www.mozilla.org/MPL/
|
||||||
|
+##
|
||||||
|
+## Software distributed under the License is distributed on an "AS IS"
|
||||||
|
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||||
|
+## the License for the specific language governing rights and
|
||||||
|
+## limitations under the License.
|
||||||
|
##
|
||||||
|
-## Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved.
|
||||||
|
+## The Original Code is RabbitMQ.
|
||||||
|
+##
|
||||||
|
+## The Initial Developer of the Original Code is VMware, Inc.
|
||||||
|
+## Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
|
||||||
|
##
|
||||||
|
|
||||||
|
##
|
||||||
|
@@ -22,7 +30,9 @@
|
||||||
|
## OCF_RESKEY_mnesia_base
|
||||||
|
## OCF_RESKEY_server_start_args
|
||||||
|
## OCF_RESKEY_pid_file
|
||||||
|
-## OCF_RESKEY_limit_nofile
|
||||||
|
+## WRS
|
||||||
|
+# OCF_RESKEY_env_config_file
|
||||||
|
+# OCF_RESKEY_dist_port
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Initialization:
|
||||||
|
@@ -32,18 +42,18 @@
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
+. /etc/platform/platform.conf
|
||||||
|
+
|
||||||
|
OCF_RESKEY_server_default="/usr/sbin/rabbitmq-server"
|
||||||
|
OCF_RESKEY_ctl_default="/usr/sbin/rabbitmqctl"
|
||||||
|
OCF_RESKEY_nodename_default="rabbit@localhost"
|
||||||
|
OCF_RESKEY_log_base_default="/var/log/rabbitmq"
|
||||||
|
OCF_RESKEY_pid_file_default="/var/run/rabbitmq/pid"
|
||||||
|
-OCF_RESKEY_limit_nofile_default=65535
|
||||||
|
: ${OCF_RESKEY_server=${OCF_RESKEY_server_default}}
|
||||||
|
: ${OCF_RESKEY_ctl=${OCF_RESKEY_ctl_default}}
|
||||||
|
: ${OCF_RESKEY_nodename=${OCF_RESKEY_nodename_default}}
|
||||||
|
: ${OCF_RESKEY_log_base=${OCF_RESKEY_log_base_default}}
|
||||||
|
: ${OCF_RESKEY_pid_file=${OCF_RESKEY_pid_file_default}}
|
||||||
|
-: ${OCF_RESKEY_limit_nofile=${OCF_RESKEY_limit_nofile_default}}
|
||||||
|
|
||||||
|
meta_data() {
|
||||||
|
cat <<END
|
||||||
|
@@ -139,14 +149,6 @@ Location of the file in which the pid will be stored
|
||||||
|
<content type="string" default="${OCF_RESKEY_pid_file_default}" />
|
||||||
|
</parameter>
|
||||||
|
|
||||||
|
-<parameter name="limit_nofile" unique="0" required="0">
|
||||||
|
-<longdesc lang="en">
|
||||||
|
-Soft and hard limit for NOFILE
|
||||||
|
-</longdesc>
|
||||||
|
-<shortdesc lang="en">NOFILE limit</shortdesc>
|
||||||
|
-<content type="string" default="${OCF_RESKEY_limit_nofile_default}" />
|
||||||
|
-</parameter>
|
||||||
|
-
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<actions>
|
||||||
|
@@ -175,14 +177,25 @@ RABBITMQ_NODENAME=$OCF_RESKEY_nodename
|
||||||
|
RABBITMQ_NODE_IP_ADDRESS=$OCF_RESKEY_ip
|
||||||
|
RABBITMQ_NODE_PORT=$OCF_RESKEY_port
|
||||||
|
RABBITMQ_CONFIG_FILE=$OCF_RESKEY_config_file
|
||||||
|
+RABBITMQ_CONF_ENV_FILE=$OCF_RESKEY_env_config_file
|
||||||
|
+RABBITMQ_DIST_PORT=$OCF_RESKEY_dist_port
|
||||||
|
RABBITMQ_LOG_BASE=$OCF_RESKEY_log_base
|
||||||
|
RABBITMQ_MNESIA_BASE=$OCF_RESKEY_mnesia_base
|
||||||
|
RABBITMQ_SERVER_START_ARGS=$OCF_RESKEY_server_start_args
|
||||||
|
RABBITMQ_PID_FILE=$OCF_RESKEY_pid_file
|
||||||
|
-RABBITMQ_LIMIT_NOFILE=$OCF_RESKEY_limit_nofile
|
||||||
|
[ ! -z $RABBITMQ_NODENAME ] && NODENAME_ARG="-n $RABBITMQ_NODENAME"
|
||||||
|
[ ! -z $RABBITMQ_NODENAME ] && export RABBITMQ_NODENAME
|
||||||
|
|
||||||
|
+#
|
||||||
|
+# Make sure a HOME directory is set and exported for rabbitmqctl
|
||||||
|
+# to work, otherwise an error "erlexec: HOME must be set" will
|
||||||
|
+# result. Erlang exec requires a HOME directory to be set.
|
||||||
|
+# Rabbit-Server will source a different directory from the config
|
||||||
|
+# file.
|
||||||
|
+#
|
||||||
|
+HOME=/tmp
|
||||||
|
+export HOME
|
||||||
|
+
|
||||||
|
ensure_pid_dir () {
|
||||||
|
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
||||||
|
if [ ! -d ${PID_DIR} ] ; then
|
||||||
|
@@ -201,20 +214,15 @@ remove_pid () {
|
||||||
|
export_vars() {
|
||||||
|
[ ! -z $RABBITMQ_NODE_IP_ADDRESS ] && export RABBITMQ_NODE_IP_ADDRESS
|
||||||
|
[ ! -z $RABBITMQ_NODE_PORT ] && export RABBITMQ_NODE_PORT
|
||||||
|
+ [ ! -z $RABBITMQ_DIST_PORT ] && export RABBITMQ_DIST_PORT
|
||||||
|
[ ! -z $RABBITMQ_CONFIG_FILE ] && export RABBITMQ_CONFIG_FILE
|
||||||
|
+ [ ! -z $RABBITMQ_CONF_ENV_FILE ] && export RABBITMQ_CONF_ENV_FILE
|
||||||
|
[ ! -z $RABBITMQ_LOG_BASE ] && export RABBITMQ_LOG_BASE
|
||||||
|
[ ! -z $RABBITMQ_MNESIA_BASE ] && export RABBITMQ_MNESIA_BASE
|
||||||
|
[ ! -z $RABBITMQ_SERVER_START_ARGS ] && export RABBITMQ_SERVER_START_ARGS
|
||||||
|
[ ! -z $RABBITMQ_PID_FILE ] && ensure_pid_dir && export RABBITMQ_PID_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
-set_limits() {
|
||||||
|
- local current_limit=$(su rabbitmq -s /bin/sh -c "ulimit -n")
|
||||||
|
- if [ ! -z $RABBITMQ_LIMIT_NOFILE -a $RABBITMQ_LIMIT_NOFILE -gt $current_limit ] ; then
|
||||||
|
- ulimit -n $RABBITMQ_LIMIT_NOFILE
|
||||||
|
- fi
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
rabbit_validate_partial() {
|
||||||
|
if [ ! -x $RABBITMQ_SERVER ]; then
|
||||||
|
ocf_log err "rabbitmq-server server $RABBITMQ_SERVER does not exist or is not executable";
|
||||||
|
@@ -249,26 +257,39 @@ rabbit_validate_full() {
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbit_status() {
|
||||||
|
+ # The rabbitmqctl command requires the erlang cookie to be available or it
|
||||||
|
+ # crashes. If we are on the standby controller, the rabbit filesystem
|
||||||
|
+ # (and the cookie) are not available, so lets fail gracefully here if the
|
||||||
|
+ # rabbit database directory is not visible.
|
||||||
|
+ if [ ! -z $RABBITMQ_MNESIA_BASE ] && [ ! -d $RABBITMQ_MNESIA_BASE ]; then
|
||||||
|
+ ocf_log debug "Not checking status because rabbitmq-server mnesia_base $RABBITMQ_MNESIA_BASE does not exist or is not a directory";
|
||||||
|
+ exit $OCF_NOT_RUNNING;
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
rabbitmqctl_action "status"
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbit_wait() {
|
||||||
|
- rabbitmqctl_action "wait" $1
|
||||||
|
+ rabbitmqctl_action "wait" "--timeout" "85" $1
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitmqctl_action() {
|
||||||
|
local rc
|
||||||
|
local action
|
||||||
|
action=$@
|
||||||
|
- ocf_run -q -info $RABBITMQ_CTL $NODENAME_ARG $action
|
||||||
|
+ $RABBITMQ_CTL $NODENAME_ARG $action > /dev/null 2> /dev/null
|
||||||
|
rc=$?
|
||||||
|
case "$rc" in
|
||||||
|
0)
|
||||||
|
ocf_log debug "RabbitMQ server is running normally"
|
||||||
|
return $OCF_SUCCESS
|
||||||
|
;;
|
||||||
|
- 1|2|69)
|
||||||
|
- ocf_log debug "RabbitMQ server is not running"
|
||||||
|
+ # Error code 69 is returned as failed to connect to node and added as a
|
||||||
|
+ # not running case for proper handling on status command
|
||||||
|
+ # TODO: this should be revisited at some point to try not to be specific
|
||||||
|
+ # but generic for any non-zero return to be handled consistently
|
||||||
|
+ 2|69)
|
||||||
|
+ ocf_log debug "RabbitMQ server is not running: $rc"
|
||||||
|
return $OCF_NOT_RUNNING
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
@@ -287,10 +308,29 @@ rabbit_start() {
|
||||||
|
|
||||||
|
export_vars
|
||||||
|
|
||||||
|
- # RabbitMQ requires high soft and hard limits for NOFILE
|
||||||
|
- set_limits
|
||||||
|
-
|
||||||
|
- setsid sh -c "$RABBITMQ_SERVER > ${RABBITMQ_LOG_BASE}/startup_log 2> ${RABBITMQ_LOG_BASE}/startup_err" &
|
||||||
|
+ # Increase the maximum number of file descriptors that can be open at
|
||||||
|
+ # once - required for large systems.
|
||||||
|
+ ulimit -n 8192
|
||||||
|
+ if [ "${system_type}" = "All-in-one" ]; then
|
||||||
|
+ # Rabbit/beam related tasks should be on platform cores from the get go.
|
||||||
|
+ # If they are affined to all cores during initialization sequence of AIO,
|
||||||
|
+ # the system will end up with many extra beam threads that are not in use.
|
||||||
|
+ source /etc/init.d/cpumap_functions.sh
|
||||||
|
+ PLATFORM_CPULIST=$(platform_expanded_cpu_list)
|
||||||
|
+ PLATFORM_CPUS=$(get_platform_cpus)
|
||||||
|
+ # Calculate thread pool size based on PLATFORM_CPUS
|
||||||
|
+ # Refer to: https://github.com/rabbitmq/rabbitmq-common/commit/4f9ef33cf9ba52197ff210ffcdf6629c1b7a6e9e
|
||||||
|
+ RABBITMQ_IO_THREAD_POOL_SIZE=$((${PLATFORM_CPUS} * 16))
|
||||||
|
+ if [ ${RABBITMQ_IO_THREAD_POOL_SIZE} -lt 64 ]; then
|
||||||
|
+ RABBITMQ_IO_THREAD_POOL_SIZE=64
|
||||||
|
+ elif [ ${RABBITMQ_IO_THREAD_POOL_SIZE} -gt 1024 ]; then
|
||||||
|
+ RABBITMQ_IO_THREAD_POOL_SIZE=1024
|
||||||
|
+ fi
|
||||||
|
+ export RABBITMQ_IO_THREAD_POOL_SIZE
|
||||||
|
+ setsid sh -c "exec taskset -c ${PLATFORM_CPULIST} $RABBITMQ_SERVER >> ${RABBITMQ_LOG_BASE}/startup_log 2>> ${RABBITMQ_LOG_BASE}/startup_err" &
|
||||||
|
+ else
|
||||||
|
+ setsid sh -c "$RABBITMQ_SERVER >> ${RABBITMQ_LOG_BASE}/startup_log 2>> ${RABBITMQ_LOG_BASE}/startup_err" &
|
||||||
|
+ fi
|
||||||
|
|
||||||
|
# Wait for the server to come up.
|
||||||
|
# Let the CRM/LRM time us out if required
|
||||||
|
@@ -310,15 +350,30 @@ rabbit_stop() {
|
||||||
|
|
||||||
|
if ! rabbit_status; then
|
||||||
|
ocf_log info "Resource not running."
|
||||||
|
- return $OCF_SUCCESS
|
||||||
|
+
|
||||||
|
+ # On rare occasions, the status check could indicate rabbitmq is not running,
|
||||||
|
+ # but there could be partial service. As such, ignore this case and just fall
|
||||||
|
+ # through to continue with the stop
|
||||||
|
+ #
|
||||||
|
+ # return $OCF_SUCCESS
|
||||||
|
fi
|
||||||
|
|
||||||
|
- rabbitmqctl_action stop ${RABBITMQ_PID_FILE}
|
||||||
|
+ if [ -f "$RABBITMQ_PID_FILE" ]; then
|
||||||
|
+ $RABBITMQ_CTL stop "$RABBITMQ_PID_FILE"
|
||||||
|
+ else
|
||||||
|
+ $RABBITMQ_CTL stop
|
||||||
|
+ fi
|
||||||
|
rc=$?
|
||||||
|
|
||||||
|
if [ "$rc" != 0 ]; then
|
||||||
|
ocf_log err "rabbitmq-server stop command failed: $RABBITMQ_CTL stop, $rc"
|
||||||
|
- return $rc
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ process_info=$(ss -ntlp | grep -w 5672 | awk '{print $6}' | sed 1q)
|
||||||
|
+
|
||||||
|
+ if [ ! -z "${process_info}" ]; then
|
||||||
|
+ ocf_log err "rabbitmq-server stop command executed: '$RABBITMQ_CTL stop $RABBITMQ_PID_FILE', but port is still in use by ${process_info}."
|
||||||
|
+ exit $OCF_ERR_GENERIC
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Spin waiting for the server to shut down.
|
||||||
|
@@ -363,6 +418,8 @@ else
|
||||||
|
rabbit_validate_full
|
||||||
|
fi
|
||||||
|
|
||||||
|
+export_vars
|
||||||
|
+
|
||||||
|
case $__OCF_ACTION in
|
||||||
|
start)
|
||||||
|
rabbit_start
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
0001-WRS-Allow-rabbitmqctl-to-run-as-root-and-set-root-ho.patch
|
0001-WRS-Allow-rabbitmqctl-to-run-as-root-and-set-root-ho.patch
|
||||||
|
0002-Change-rabbitmq-server-configuration-files.patch
|
||||||
|
|
Loading…
Reference in New Issue