refector: 正式环境500才发邮件
This commit is contained in:
parent
8628d0a74b
commit
3c91e23cec
|
@ -10,6 +10,7 @@ myLogger = logging.getLogger('log')
|
|||
|
||||
@shared_task
|
||||
def send_mail_task(**args):
|
||||
if settings.DEBUG is False:
|
||||
from django.core.mail import send_mail
|
||||
args['subject'] = args.get('subject', '{}:{}_{}_500'.format(settings.SYS_NAME, settings.SYS_VERSION, settings.PROJECT_NAME))
|
||||
args['from_email'] = args.get('from_email', settings.EMAIL_HOST_USER)
|
||||
|
@ -23,6 +24,7 @@ class CustomTask(Task):
|
|||
"""
|
||||
|
||||
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
||||
if settings.DEBUG is False:
|
||||
detail = '{0!r} failed: {1!r}'.format(task_id, exc)
|
||||
myLogger.error(detail)
|
||||
send_mail_task.delay(subject='{}:{}_{}_task_error'.format(settings.SYS_NAME, settings.SYS_VERSION, settings.PROJECT_NAME), message=detail)
|
||||
|
|
Loading…
Reference in New Issue