#!/bin/sh # # repmgrd Start repmgrd daemon # # chkconfig: - 64 36 # description: repmgrd is replication manager, and failover management tool ## BEGIN INIT INFO # Provides: repmgrd # Required-Start: $local_fs $remote_fs $network $syslog $named # Required-Stop: $local_fs $remote_fs $network $syslog $named # Should-Start: postgresql # Short-Description: Start repmgrd daemon # Description: repmgrd is replication manager, and failover management tool ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions exec=/usr/pgsql-9.4/bin/repmgrd user=repmgr prog=repmgrd pidfile=/var/run/repmgr/repmgrd.pid lockfile=/var/lock/subsys/$prog REPMGRDCONF=/etc/repmgr/repmgr.conf REPMGRDLOG=/var/log/repmgr/repmgrd.log # Get config. . /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 6 start(){ [ -x $exec ] || exit 5 [ -f "$REPMGRDCONF" ] || exit 6 echo -n "Starting $prog: " # Make sure startup-time log file is valid 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 fi mkdir -p $(dirname $pidfile) chown $user: $(dirname $pidfile) # daemon --user=pgbouncer --pidfile=$pidfile $exec -d -q $BOUNCERCONF su -c "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1" $user # --monitoring-history --verbose #daemon --user=repmgr "$exec -f $REPMGRDCONF -p $pidfile -d ->> $REPMGRDLOG 2>&1 " retval=$? [ $retval -eq 0 ] && success echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop(){ echo -n "Stopping $prog: " killproc -p $pidfile $prog -TERM retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart(){ if rh_status_q; then stop start else start fi } reload(){ echo -n "Reloading $prog: " kill -HUP $(cat $pidfile) retval=$? echo return $retval } rh_status() { if [ -f $pidfile ] && [ `ps hp $(cat $pidfile)|wc -l` -eq 1 ] then pid=$(cat $pidfile) echo "Process repmgrd exists (PID $pid)" return 0 else return 1 fi } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 start ;; stop) rh_status_q || exit 0 stop ;; restart) restart ;; reload|force-reload) rh_status_q || exit 7 reload ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" exit 2 esac exit $?