public inbox for [email protected]
help / color / mirror / Atom feedFrom: Martín Marqués <[email protected]>
To: [email protected]
Subject: repmgr init script
Date: Mon, 28 Sep 2015 18:57:03 -0300
Message-ID: <[email protected]> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-pkg-yum>
Hi all,
I've been going over the configuration of an already installed repmgr
cluster from PGDG rpms and found that the init-script doesn't seem to be
performing the correct commands.
I found a dangling dash which I have no idea what it's there for.
So, mainly I think the start exec should be changed to something like:
$SU -l $REPMGRD_USER -c "${REPMGRD_BIN} ${REPMGRD_OPTS} \
-p ${REPMGRD_PIDFILE} &" >> "${REPMGRD_LOG}" 2>&1 < /dev/null
This means having all the repmgrd options set in ${REPMGRD_OPTS} in a
sysconfig file instead of placing them one by one in the init script.
This would mean that all the configuration should be set in
sysconfig/repmgrd, not by editing the init script.
Attached is a patch for EL-6, plus the missing sysconfig file.
On EL-7 we need to have a nice systemd file. I'll see if I can get that
done later.
Also, the init script's service should be called repmgrd, not repmgr.
Kind regards,
--
Martín Marqués http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
# default settings for repmgrd. This file is source by /bin/sh from
# /etc/init.d/repmgrd
# disable repmgrd by default so it won't get started upon installation
# valid values: yes/no
REPMGRD_ENABLED=no
# Repmgr conf file
REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
# Options for repmgrd (required)
#REPMGRD_OPTS="--verbose -d "
# User to run repmgrd as
#REPMGRD_USER=postgres
# repmgrd binary
#REPMGRD_BIN=/usr/bin/repmgrd
# pid file
#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
# log file
#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
--
Sent via pgsql-pkg-yum mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-yum
Attachments:
[text/x-diff] repmgr.init.diff (2.3K, 2-repmgr.init.diff)
download | inline diff:
diff --git a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
index c900170..fd0fdd2 100644
--- a/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
+++ b/rpm/redhat/9.4/repmgr/EL-6/repmgr.init
@@ -29,32 +29,63 @@ user=repmgr
prog=repmgrd
pidfile=/var/run/repmgr/repmgrd-9.4.pid
lockfile=/var/lock/subsys/$prog
+REPMGRD_ENABLED=no
+REPMGRD_OPTS=
REPMGRDCONF=/etc/repmgr/9.4/repmgr.conf
REPMGRDLOG=/var/log/repmgr/repmgrd-9.4.log
# Get config.
. /etc/sysconfig/network
+# Read configuration variable file if it is present
+[ -r /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+ SU=runuser
+else
+ SU=su
+fi
+
+test -x $exec || exit 0
+
+case "$REPMGRD_ENABLED" in
+ [Yy]*)
+ break
+ ;;
+ *)
+ exit 0
+ ;;
+esac
+
+if [ -z "${REPMGRD_OPTS}" ]
+then
+ echo "Not starting ${prog}, REPMGRD_OPTS not set in /etc/sysconfig/${prog}"
+ exit 0
+fi
+
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 6
start(){
[ -x $exec ] || exit 5
- [ -f "$REPMGRDCONF" ] || exit 6
+ [ -f "${REPMGRDCONF}" ] || exit 6
echo -n "Starting $prog: "
# Make sure startup-time log file is valid
- if [ ! -e "$REPMGRDLOG" -a ! -h "$REPMGRDLOG" ]
+ if [ ! -e "${REPMGRDLOG}" -a ! -h "${REPMGRDLOG}" ]
then
- touch "$REPMGRDLOG" || exit 1
- chown $user: "$REPMGRDLOG"
- chmod go-rwx "$REPMGRDLOG"
- [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$REPMGRDLOG" 2>/dev/null
+ touch "${REPMGRDLOG}" || exit 1
+ chown $user: "${REPMGRDLOG}"
+ chmod go-rwx "${REPMGRDLOG}"
+ [ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "${REPMGRDLOG}" 2>/dev/null
fi
mkdir -p $(dirname $pidfile)
chown $user: $(dirname $pidfile)
- su -l repmgr -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose
+ ${SU} -l -c "${exec} -f ${REPMGR_CONF} ${REPMGRD_OPTS} -p ${pidfile} >> ${REPMGRDLOG} 2>&1" ${user} < /dev/null
+ sleep 2
retval=$?
[ $retval -eq 0 ] && success
echo
[text/plain] repmgrd.sysconfig (553B, 3-repmgrd.sysconfig)
download | inline:
# default settings for repmgrd. This file is source by /bin/sh from
# /etc/init.d/repmgrd
# disable repmgrd by default so it won't get started upon installation
# valid values: yes/no
REPMGRD_ENABLED=no
# Repmgr conf file
REPMGR_CONF=/var/lib/pgsql/repmgr/repmgr.conf
# Options for repmgrd (required)
#REPMGRD_OPTS="--verbose -d "
# User to run repmgrd as
#REPMGRD_USER=postgres
# repmgrd binary
#REPMGRD_BIN=/usr/bin/repmgrd
# pid file
#REPMGRD_PIDFILE=/var/lib/pgsql/repmgr/repmgrd.pid
# log file
#REPMGRD_LOG=/var/lib/pgsql/repmgr/repmgrd.log
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: repmgr init script
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox