[Unit] Description=PostgreSQL database server After=network.target [Service] User=postgres # XXX: See issue https://bugs.freedesktop.org/show_bug.cgi?id=35387 - we cannot use %I in these options at the moment #Environment=PGDATA=/var/lib/postgresql/%I/main ExecStart=/bin/sh -c 'PGDATA=/var/lib/postgresql/%I/main exec /usr/lib/postgresql/%I/bin/postgres -c config_file=/etc/postgresql/%I/main/postgresql.conf >>/var/log/postgresql/postgresql-%I-main.log' # Use pg_ctl stop to shutdown the server, do not attempt to kill the processes. # It does some more checks (online backups) which we don't want to duplicate. ExecStop=/bin/sh -c 'PGDATA=/var/lib/postgresql/%I/main exec /usr/lib/postgresql/%I/bin/pg_ctl stop -m fast -s -w -t 20' KillMode=none [Install] WantedBy=multi-user.target