Add PostgreSQL 9.3 use case to kill postgresql processes

This commit is contained in:
jmartin 2014-09-23 16:10:26 +02:00
parent f0d9d1788a
commit 808a0f5e68

View file

@ -43,7 +43,7 @@ def create_db_copy(user, password, dbname, port=5432):
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
process.wait()
else:
elif version == '9.2':
process = subprocess.Popen("""
export PGPASSWORD="erpdbcopy"
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with superuser"
@ -56,6 +56,19 @@ def create_db_copy(user, password, dbname, port=5432):
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
process.wait()
else:
process = subprocess.Popen("""
export PGPASSWORD="erpdbcopy"
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with superuser"
export PGPASSWORD=%(password)s
psql %(dbname)s -U %(user)s --quiet -c "select pg_terminate_backend(pid) from pg_stat_activity where pid <> pg_backend_pid() and datname='%(dbname)s'"
psql %(dbname)s_test -U %(user)s --quiet -c "select pg_terminate_backend(pid) from pg_stat_activity where pid <> pg_backend_pid() and datname='%(dbname)s_test'"
dropdb -U %(user)s %(dbname)s_test
createdb -U %(user)s -T %(dbname)s %(dbname)s_test -O %(user)s
export PGPASSWORD="erpdbcopy"
psql postgres -U erpdbcopy --quiet -c "alter user %(user)s with nosuperuser"
export PGPASSWORD=""" % {'user': user, 'password': password, 'dbname': dbname}, shell=True)
process.wait()
try:
logging.info('Dissable crons copy: %s_test' % dbname)