fix(proxy_cli.py): ensure proxy always retries if db push fails to connect to db

This commit is contained in:
Krrish Dholakia 2024-01-17 17:37:59 -08:00
parent 7a80df83b2
commit 3bdfb2bc6d

View file

@ -405,6 +405,7 @@ def run_server(
is_prisma_runnable = False is_prisma_runnable = False
if is_prisma_runnable: if is_prisma_runnable:
for _ in range(4):
# run prisma db push, before starting server # run prisma db push, before starting server
# Save the current working directory # Save the current working directory
original_dir = os.getcwd() original_dir = os.getcwd()
@ -413,9 +414,10 @@ def run_server(
dname = os.path.dirname(abspath) dname = os.path.dirname(abspath)
os.chdir(dname) os.chdir(dname)
try: try:
subprocess.run( subprocess.run(["prisma", "db", "push", "--accept-data-loss"])
["prisma", "db", "push", "--accept-data-loss"] break # Exit the loop if the subprocess succeeds
) # this looks like a weird edge case when prisma just wont start on render. we need to have the --accept-data-loss except subprocess.CalledProcessError as e:
print(f"Error: {e}")
finally: finally:
os.chdir(original_dir) os.chdir(original_dir)
else: else: