# patroni - patroni daemon
#
# controls startup/shutdown of postgres
# you should disable any postgres start jobs
#
# assumes that patroni has been installed into the
# pythonpath by using setup.py install

description    "patroni start daemon"

start on net-device-up
stop on runlevel [06]

respawn
respawn limit 5 10

# set location of patroni
env PATRONI=/usr/local/bin/patroni
# virtualenv example
# env PATRONI=/var/lib/postgresql/patronienv/bin/patroni

# set location of config file
env PATRONICONF=/etc/patroni/patroni.yml

# set log dir for patroni logs
# postgres user must have write permission
env POSTGRESLOGDIR=/var/log/postgresql

setuid postgres
setgid postgres

script
    exec start-stop-daemon --start \
        --exec $PATRONI -- $PATRONICONF \
        >> $POSTGRESLOGDIR/patroni.log 2>&1
end script
