Skip to content

Instantly share code, notes, and snippets.

@frozencemetery
Created October 13, 2015 18:11
Show Gist options
  • Save frozencemetery/1da797f4559626a7370a to your computer and use it in GitHub Desktop.
Save frozencemetery/1da797f4559626a7370a to your computer and use it in GitHub Desktop.
Postgres server launcher so that I can pretend the server stays in the foreground
#!/usr/bin/env python3
import subprocess
import sys
def main(argv):
print(subprocess.getoutput("pg_ctl -D /var/lib/pgsql/data -l logfile start"))
try:
tail = subprocess.Popen(["tail", "-F", "logfile"], stdout=sys.stdout)
tail.wait()
pass
except:
print("Took exception; killing server...")
pass
print(subprocess.getoutput("pg_ctl -D /var/lib/pgsql/data -l logfile stop"))
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment