Patch startup scripts in-place and install them rather then install a modified copy of them
This commit is contained in:
parent
1d683abdb2
commit
180e97b96e
1
debian/patches/series
vendored
1
debian/patches/series
vendored
|
@ -1,2 +1,3 @@
|
|||
pgpass_in_testsuite.patch
|
||||
sphinx_no_mathjax.patch
|
||||
startup_scripts.patch
|
||||
|
|
59
debian/patches/startup_scripts.patch
vendored
Normal file
59
debian/patches/startup_scripts.patch
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
--- ./extras/startup-scripts/patroni 2017-09-08 10:56:09.000000000 +0200
|
||||
+++ debian/patroni.init 2017-09-14 14:49:36.103403273 +0200
|
||||
@@ -18,7 +18,7 @@
|
||||
GROUP="postgres"
|
||||
|
||||
NAME=patroni
|
||||
-PATRONI="/opt/patroni/$NAME.py"
|
||||
+PATRONI="/usr/bin/$NAME"
|
||||
PIDFILE="/var/run/$NAME.pid"
|
||||
|
||||
# Set this parameter, if you have several Postgres versions installed
|
||||
@@ -114,6 +114,12 @@
|
||||
kill -HUP $CHILDPID
|
||||
;;
|
||||
|
||||
+ force-reload)
|
||||
+ log_success_msg "Rorce-reloading Patroni configuration"
|
||||
+ get_pid
|
||||
+ kill -HUP $CHILDPID
|
||||
+ ;;
|
||||
+
|
||||
status)
|
||||
get_pid
|
||||
if start-stop-daemon -T --pid $CHILDPID; then
|
||||
@@ -130,7 +136,7 @@
|
||||
;;
|
||||
|
||||
*)
|
||||
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|status}"
|
||||
+ echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
--- ./extras/startup-scripts/patroni.service 2017-09-08 10:56:09.000000000 +0200
|
||||
+++ debian/patroni.service 2017-09-14 14:50:02.095431685 +0200
|
||||
@@ -1,9 +1,6 @@
|
||||
-# This is an example systemd config file for Patroni
|
||||
-# You can copy it to "/etc/systemd/system/patroni.service",
|
||||
-
|
||||
[Unit]
|
||||
Description=Runners to orchestrate a high-availability PostgreSQL
|
||||
-After=syslog.target network.target
|
||||
+After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
@@ -11,11 +8,7 @@
|
||||
User=postgres
|
||||
Group=postgres
|
||||
|
||||
-# Where to send early-startup messages from the server
|
||||
-# This is normally controlled by the global default set by systemd
|
||||
-# StandardOutput=syslog
|
||||
-
|
||||
-ExecStart=/bin/patroni /etc/patroni.yml
|
||||
+ExecStart=/usr/bin/patroni /etc/patroni/config.yml
|
||||
|
||||
# only kill the patroni process, not it's children, so it will gracefully stop postgres
|
||||
KillMode=process
|
150
debian/patroni.init
vendored
150
debian/patroni.init
vendored
|
@ -1,150 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: patroni
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Patroni init script
|
||||
# Description: Runners to orchestrate a high-availability PostgreSQL
|
||||
### END INIT INFO
|
||||
|
||||
### BEGIN USER CONFIGURATION
|
||||
|
||||
CONF="/etc/patroni/postgres.yml"
|
||||
LOGFILE="/var/log/patroni.log"
|
||||
USER="postgres"
|
||||
GROUP="postgres"
|
||||
|
||||
NAME=patroni
|
||||
PATRONI="/usr/bin/$NAME"
|
||||
PIDFILE="/var/run/$NAME.pid"
|
||||
|
||||
# Set this parameter, if you have several Postgres versions installed
|
||||
# POSTGRES_VERSION="9.4"
|
||||
POSTGRES_VERSION=""
|
||||
|
||||
### END USER CONFIGURATION
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Loading this library for get_versions() function
|
||||
if test ! -e /usr/share/postgresql-common/init.d-functions; then
|
||||
log_failure_msg "Probably postgresql-common does not installed."
|
||||
exit 1
|
||||
else
|
||||
. /usr/share/postgresql-common/init.d-functions
|
||||
fi
|
||||
|
||||
# Is there Patroni executable?
|
||||
if test ! -e $PATRONI; then
|
||||
log_failure_msg "Patroni executable $PATRONI does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Is there Patroni configuration file?
|
||||
if test ! -e $CONF; then
|
||||
log_failure_msg "Patroni configuration file $CONF does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create logfile if doesn't exist
|
||||
if test ! -e $LOGFILE; then
|
||||
log_action_msg "Creating logfile for Patroni..."
|
||||
touch $LOGFILE
|
||||
chown $USER:$GROUP $LOGFILE
|
||||
fi
|
||||
|
||||
prepare_pgpath() {
|
||||
if [ "$POSTGRES_VERSION" != "" ]; then
|
||||
if [ -x /usr/lib/postgresql/$POSTGRES_VERSION/bin/pg_ctl ]; then
|
||||
PGPATH="/usr/lib/postgresql/$POSTGRES_VERSION/bin"
|
||||
else
|
||||
log_failure_msg "Postgres version incorrect, check POSTGRES_VERSION variable."
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
get_versions
|
||||
if echo $versions | grep -q -e "\s"; then
|
||||
log_warning_msg "You have several Postgres versions installed. Please, use POSTGRES_VERSION to define correct environment."
|
||||
else
|
||||
versions=`echo $versions | sed -e 's/^[ \t]*//'`
|
||||
PGPATH="/usr/lib/postgresql/$versions/bin"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_pid() {
|
||||
if test -e $PIDFILE; then
|
||||
PID=`cat $PIDFILE`
|
||||
CHILDPID=`ps --ppid $PID -o %p --no-headers`
|
||||
else
|
||||
log_failure_msg "Could not find PID file. Patroni probably down."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
prepare_pgpath
|
||||
PGPATH=$PATH:$PGPATH
|
||||
log_success_msg "Starting Patroni\n"
|
||||
exec start-stop-daemon --start --quiet \
|
||||
--background \
|
||||
--pidfile $PIDFILE --make-pidfile \
|
||||
--chuid $USER:$GROUP \
|
||||
--chdir `eval echo ~$USER` \
|
||||
--exec $PATRONI \
|
||||
--startas /bin/sh -- \
|
||||
-c "/usr/bin/env PATH=$PGPATH /usr/bin/python $PATRONI $CONF >> $LOGFILE 2>&1"
|
||||
;;
|
||||
|
||||
stop)
|
||||
log_success_msg "Stopping Patroni"
|
||||
get_pid
|
||||
start-stop-daemon --stop --pid $CHILDPID
|
||||
start-stop-daemon --stop --pidfile $PIDFILE --remove-pidfile --quiet
|
||||
;;
|
||||
|
||||
reload)
|
||||
log_success_msg "Reloading Patroni configuration"
|
||||
get_pid
|
||||
kill -HUP $CHILDPID
|
||||
;;
|
||||
|
||||
force-reload)
|
||||
log_success_msg "Rorce-reloading Patroni configuration"
|
||||
get_pid
|
||||
kill -HUP $CHILDPID
|
||||
;;
|
||||
|
||||
status)
|
||||
get_pid
|
||||
if start-stop-daemon -T --pid $CHILDPID; then
|
||||
log_success_msg "Patroni is running\n"
|
||||
exit 0
|
||||
else
|
||||
log_warning_msg "Patroni in not running\n"
|
||||
fi
|
||||
;;
|
||||
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo .
|
||||
exit 0
|
||||
else
|
||||
echo " failed"
|
||||
exit 1
|
||||
fi
|
24
debian/patroni.service
vendored
24
debian/patroni.service
vendored
|
@ -1,24 +0,0 @@
|
|||
[Unit]
|
||||
Description=Runners to orchestrate a high-availability PostgreSQL
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
User=postgres
|
||||
Group=postgres
|
||||
|
||||
ExecStart=/usr/bin/patroni /etc/patroni/config.yml
|
||||
|
||||
# only kill the patroni process, not it's children, so it will gracefully stop postgres
|
||||
KillMode=process
|
||||
|
||||
# Give a reasonable amount of time for the server to start up/shut down
|
||||
TimeoutSec=30
|
||||
|
||||
# Do not restart the service if it crashes, we want to manually inspect database on failure
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
5
debian/rules
vendored
5
debian/rules
vendored
|
@ -15,6 +15,11 @@ override_dh_auto_build:
|
|||
dh_auto_build
|
||||
(cd docs; $(MAKE) html)
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install
|
||||
tr -d '\r' < extras/startup-scripts/patroni > debian/patroni.init
|
||||
cp extras/startup-scripts/patroni.service debian/
|
||||
|
||||
override_dh_installdocs:
|
||||
dh_installdocs
|
||||
dh_sphinxdoc /usr/share/doc/patroni/html
|
||||
|
|
Loading…
Reference in a new issue