billing frontend for mariadb. setup as otb_billing for outsidethebox.top accounting. also involved with outsidethedb
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.
 
 
 
 

60 lines
1.7 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("email"),
subject=subject,
body=body,
attachments=attachments,
email_type="payment_received",
invoice_id=invoice_id
)
return True
except Exception:
return False
'''
new = ''' import time
for attempt in range(3):
try:
send_configured_email(
to_email=invoice_email_row.get("email"),
subject=subject,
body=body,
attachments=attachments,
email_type="payment_received",
invoice_id=invoice_id
)
return True
except Exception as e:
print(f"[email retry] invoice_id={invoice_id} attempt={attempt+1} error={type(e).__name__}: {e}")
if attempt < 2:
time.sleep(2)
print(f"[send_payment_received_email] FAILED after retries invoice_id={invoice_id}")
return False
except Exception:
return False
'''
if old not in text:
raise SystemExit("FAILED: exact helper send block not found")
text = text.replace(old, new, 1)
p.write_text(text)
print("OK: retry logic added to helper")
PY
python3 -m py_compile app.py && echo "PY_COMPILE_OK" || echo "PY_COMPILE_FAILED"
sudo systemctl restart otb_billing
sudo systemctl status otb_billing --no-pager -l