You read my mind! Thanks for posting this.
Nice, I was looking for this. Only it does not stops postgres properly.
Hi,This scripts doesn't work properly and it might even be dangerous to your db(it's doing hard shutdown every time)this one seems to works much betterhttps://gist.github.com/haad/6020401
only the exec statement is commented out.
that one does not actually use the exec statement at all, it starts and stops in the pre and post tasks inside the looks. HOWEVER, it does not appear to work well around restarting a service that has died.