automation: add full stack trace for exceptions to logs
This commit is contained in:
parent
4be3e830c9
commit
83862ab47f
2 changed files with 10 additions and 7 deletions
|
@ -2,6 +2,7 @@ import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from traceback import TracebackException
|
||||||
|
|
||||||
from app import app
|
from app import app
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
|
@ -84,8 +85,9 @@ def run_job(job: BaseAutomation, *, force: bool = False, ignore_schedule: bool =
|
||||||
try:
|
try:
|
||||||
success, logs = job.automate()
|
success, logs = job.automate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
tb = TracebackException.from_exception(e)
|
||||||
success = False
|
success = False
|
||||||
logs = repr(e)
|
logs = "".join(tb.format())
|
||||||
if success:
|
if success:
|
||||||
automation.state = AutomationState.IDLE
|
automation.state = AutomationState.IDLE
|
||||||
automation.next_run = datetime.datetime.utcnow() + datetime.timedelta(
|
automation.next_run = datetime.datetime.utcnow() + datetime.timedelta(
|
||||||
|
|
|
@ -35,12 +35,13 @@ def mirror_mapping():
|
||||||
version="1.1",
|
version="1.1",
|
||||||
mappings={
|
mappings={
|
||||||
d.url.lstrip("https://"): MMMirror(
|
d.url.lstrip("https://"): MMMirror(
|
||||||
origin_domain=d.description[len("proxy:"):] if d.description.startswith(
|
origin_domain=d.origin.description[len("proxy:"):] if d.origin.description.startswith(
|
||||||
"proxy:") else d.domain_name,
|
"proxy:") else d.origin.domain_name,
|
||||||
origin_domain_normalized=d.description[len("proxy:"):].replace("www.", "") if d.description.startswith(
|
origin_domain_normalized=d.origin.description[len("proxy:"):].replace("www.",
|
||||||
"proxy:") else d.domain_name.replace("www.", ""),
|
"") if d.origin.description.startswith(
|
||||||
origin_domain_root=extract(d.description[len("proxy:"):] if d.description.startswith(
|
"proxy:") else d.origin.domain_name.replace("www.", ""),
|
||||||
"proxy:") else d.domain_name).registered_domain
|
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
|
) for d in Proxy.query.all() if d.url is not None
|
||||||
},
|
},
|
||||||
s3_buckets=[
|
s3_buckets=[
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue