# Start script to run pgcluu_collectd as daemon
# 
# Feel free to modify the name of the PostgreSQL service and the paths following
# your installation.
#

[Unit]
Description=Postgresql performance and auditing statistics collecting
Documentation=man:pgcluu(1)
After=postgresql.service
Wants=postgresql.service


[Service]
Type=forking
PermissionsStartOnly=true
User=postgres
Environment=STATDIR=/var/lib/pgcluu/data
Environment=PIDFILE=/run/postgresql/pgcluu_collectd.pid
ExecStartPre=-/bin/mkdir -p $STATDIR
ExecStartPre=-/bin/chown postgres:www-data $STATDIR
ExecStartPre=-/bin/chmod u=rwX,g=rsX,o= $STATDIR
ExecStart=/usr/local/bin/pgcluu_collectd --daemonize --rotate-daily --pid-file $PIDFILE $STATDIR
ExecStop=/usr/local/bin/pgcluu_collectd -k --pid-file $PIDFILE
KillMode=process
Restart=on-failure
RestartSec=60s
PIDFile=/run/postgresql/pgcluu_collectd.pid

[Install]
WantedBy=multi-user.target

