From 289620746b5a00965d2d50a161512a5975fd7ae1 Mon Sep 17 00:00:00 2001 From: Christopher Winslett Date: Thu, 19 Mar 2015 09:08:41 -0700 Subject: [PATCH] remove postgresql pid --- helpers/postgresql.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 85a301d5..7817f15a 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -78,6 +78,15 @@ class Postgresql: return os.system("pg_ctl status -D %s > /dev/null" % self.data_dir) == 0 def start(self): + if self.is_running(): + print "Cannot start PostgreSQL because one is already running." + return false + + pid_path = "%s/postmaster.pid" % self.data_dir + if os.path.exists(pid_path): + os.remove(pid_path) + print "Removed %s" % pid_path + command_code = os.system("postgres -D %s %s &" % (self.data_dir, self.server_options())) time.sleep(5) return command_code != 0