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: PASS: Build package PASS: Build and Install ISO PASS: Rabbit is running and changes are present Story: Task: Change-Id: Ie9d0539c0370858e67779a7390a73745db1a0247 Signed-off-by: mmachado <matheus.machadoguilhermino@windriver.com>
This commit is contained in:
parent
2b88224302
commit
3411bb409f
@ -0,0 +1,275 @@
|
||||
From 5e59e57a4ee90c143da57f48db189d8d972e2900 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 | 97 ++++++++++++++++++++++----------
|
||||
3 files changed, 86 insertions(+), 48 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..54efb29 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.
|
||||
+##
|
||||
+## The Original Code is RabbitMQ.
|
||||
##
|
||||
-## Copyright (c) 2018-2020 VMware, Inc. or its affiliates. All rights reserved.
|
||||
+## 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,6 +257,15 @@ 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"
|
||||
}
|
||||
|
||||
@@ -268,7 +285,7 @@ rabbitmqctl_action() {
|
||||
return $OCF_SUCCESS
|
||||
;;
|
||||
1|2|69)
|
||||
- ocf_log debug "RabbitMQ server is not running"
|
||||
+ ocf_log debug "RabbitMQ server is not running: $rc"
|
||||
return $OCF_NOT_RUNNING
|
||||
;;
|
||||
*)
|
||||
@@ -287,10 +304,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
|
||||
@@ -363,6 +399,8 @@ else
|
||||
rabbit_validate_full
|
||||
fi
|
||||
|
||||
+export_vars
|
||||
+
|
||||
case $__OCF_ACTION in
|
||||
start)
|
||||
rabbit_start
|
||||
@@ -383,3 +421,4 @@ case $__OCF_ACTION in
|
||||
esac
|
||||
|
||||
exit $?
|
||||
+
|
||||
--
|
||||
2.37.1
|
||||
|
@ -1 +1,2 @@
|
||||
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
Block a user