You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
cd /home/def/otb_billing/backend || exit 1 |
|
|
|
STAMP="$(date +%Y%m%d-%H%M%S)" |
|
cp app.py "app.py.retry-email.${STAMP}.bak" |
|
|
|
python3 <<'PY' |
|
from pathlib import Path |
|
|
|
p = Path("app.py") |
|
text = p.read_text() |
|
|
|
old = """ send_configured_email( |
|
to_email=invoice_email_row.get("client_email"), |
|
subject=subject, |
|
html_body=html, |
|
attachments=attachments |
|
) |
|
return True |
|
except Exception: |
|
return False |
|
""" |
|
|
|
new = """ import time |
|
|
|
for attempt in range(3): |
|
try: |
|
send_configured_email( |
|
to_email=invoice_email_row.get("client_email"), |
|
subject=subject, |
|
html_body=html, |
|
attachments=attachments |
|
) |
|
return True |
|
except Exception as e: |
|
print(f"[email retry] attempt {attempt+1} failed: {e}") |
|
time.sleep(2) |
|
|
|
print(f"[send_payment_received_email] FAILED after retries invoice_id={invoice_id}") |
|
return False |
|
""" |
|
|
|
if old not in text: |
|
raise SystemExit("FAILED: send email block not found") |
|
|
|
text = text.replace(old, new, 1) |
|
p.write_text(text) |
|
print("OK: retry logic added") |
|
PY |
|
|
|
python3 -m py_compile app.py && echo "PY_COMPILE_OK" || echo "PY_COMPILE_FAILED" |
|
sudo systemctl restart otb_billing
|
|
|