mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:27:09 +00:00
Disconnect DB sessions before starting upgrade
This commit is contained in:
@@ -45,6 +45,11 @@ runner = "RUNNER_NOEXPORT=true RUNNER_IMPORT=true " + os.path.join(bin_path, "ru
|
|||||||
print(system_exports)
|
print(system_exports)
|
||||||
os.system(system_exports)
|
os.system(system_exports)
|
||||||
|
|
||||||
|
print(f"Terminate all sessions in {dbname}")
|
||||||
|
cmd = f"psql -U {dbuser} -d {dbname} -c 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = current_database() AND pid <> pg_backend_pid();'"
|
||||||
|
print(cmd)
|
||||||
|
res = os.system(cmd)
|
||||||
|
|
||||||
cmd = f"psql -U {dbuser} -d template1 -c 'DROP DATABASE {dbname};'"
|
cmd = f"psql -U {dbuser} -d template1 -c 'DROP DATABASE {dbname};'"
|
||||||
print(cmd)
|
print(cmd)
|
||||||
res = os.system(cmd)
|
res = os.system(cmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user