Skip to content

Instantly share code, notes, and snippets.

@mvdbeek
Created January 4, 2016 17:30
Show Gist options
  • Save mvdbeek/5024387ddc63df91c1ad to your computer and use it in GitHub Desktop.
Save mvdbeek/5024387ddc63df91c1ad to your computer and use it in GitHub Desktop.
example script for running postgresql controlled by supervisor on real bootable machines
#!/bin/bash
# This script is run by Supervisor to start PostgreSQL 9.1 in foreground mode
function shutdown()
{
echo "Shutting down PostgreSQL"
kill $(cat /var/lib/postgresql/9.3/main/postmaster.pid)
exit 0
}
if [ -d /var/run/postgresql ]; then
chmod 2775 /var/run/postgresql
else
install -d -m 2775 -o postgres -g postgres /var/run/postgresql
fi
# Allow any signal which would kill a process to stop PostgreSQL
trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
exec sudo -u postgres /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment