automation: add full stack trace for exceptions to logs

This commit is contained in:
Iain Learmonth 2022-05-12 09:57:42 +01:00
parent 4be3e830c9
commit 83862ab47f
2 changed files with 10 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import argparse
import datetime
import json
import logging
from traceback import TracebackException
from app import app
from app.extensions import db
@ -84,8 +85,9 @@ def run_job(job: BaseAutomation, *, force: bool = False, ignore_schedule: bool =
try:
success, logs = job.automate()
except Exception as e:
tb = TracebackException.from_exception(e)
success = False
logs = repr(e)
logs = "".join(tb.format())
if success:
automation.state = AutomationState.IDLE
automation.next_run = datetime.datetime.utcnow() + datetime.timedelta(

View file

@ -35,12 +35,13 @@ def mirror_mapping():
version="1.1",
mappings={
d.url.lstrip("https://"): MMMirror(
origin_domain=d.description[len("proxy:"):] if d.description.startswith(
"proxy:") else d.domain_name,
origin_domain_normalized=d.description[len("proxy:"):].replace("www.", "") if d.description.startswith(
"proxy:") else d.domain_name.replace("www.", ""),
origin_domain_root=extract(d.description[len("proxy:"):] if d.description.startswith(
"proxy:") else d.domain_name).registered_domain
origin_domain=d.origin.description[len("proxy:"):] if d.origin.description.startswith(
"proxy:") else d.origin.domain_name,
origin_domain_normalized=d.origin.description[len("proxy:"):].replace("www.",
"") if d.origin.description.startswith(
"proxy:") else d.origin.domain_name.replace("www.", ""),
origin_domain_root=extract(d.origin.description[len("proxy:"):] if d.origin.description.startswith(
"proxy:") else d.origin.domain_name).registered_domain
) for d in Proxy.query.all() if d.url is not None
},
s3_buckets=[