Skip to content

Instantly share code, notes, and snippets.

@calvinchengx
Created June 8, 2012 11:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save calvinchengx/2895247 to your computer and use it in GitHub Desktop.
Save calvinchengx/2895247 to your computer and use it in GitHub Desktop.
systemd's postgresql.service
[Unit]
Description=PostgreSQL database server
[Service]
Type=forking
SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
# initdb script takes care for symlinking $PGROOT to /var/lib/postgres
ExecStartPre=/usr/lib/systemd/scripts/postgresql-initdb
ExecStart= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data start"
ExecReload=/bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data reload"
ExecStop= /bin/su - postgres -m -c "/usr/bin/pg_ctl -s -D /var/lib/postgres/data stop -m fast"
# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
# killing Postgres
OOMScoreAdjust=-200
[Install]
WantedBy=multi-user.target
@abhishek-yadava
Copy link

Getting error at the time of start. postgresql.service: Failed at step EXEC spawning /bin/su: Permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment