Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jannik Hellenkamp
website
Commits
9c7bbbdd
Commit
9c7bbbdd
authored
Dec 24, 2017
by
Julian Rother
Browse files
Send notifications for exceptions in scheduled functions
parent
7b9d3142
Changes
6
Hide whitespace changes
Inline
Side-by-side
scheduler.py
View file @
9c7bbbdd
...
...
@@ -22,6 +22,8 @@ def sched_func(delay, priority=0, firstdelay=None, args=[], kargs={}):
func
(
*
args
,
**
kargs
)
except
Exception
:
traceback
.
print_exc
()
notify_admins
(
'scheduler_exception'
,
name
=
func
.
__name__
,
traceback
=
traceback
.
format_exc
())
scheduler
.
enter
(
delay
,
priority
,
sched_wrapper
)
scheduler
.
enter
(
firstdelay
,
priority
,
sched_wrapper
)
print
(
"Scheduler: registered {} (frequency 1/{}s, start delay: {}s)"
.
format
(
func
.
__name__
,
delay
,
firstdelay
))
...
...
server.py
View file @
9c7bbbdd
...
...
@@ -43,10 +43,10 @@ if not config.get('SECRET_KEY', None):
config
[
'SECRET_KEY'
]
=
os
.
urandom
(
24
)
from
db
import
query
,
modify
,
show
,
searchquery
from
mail
import
notify_mods
,
notify_admins
from
ldap
import
ldapauth
from
legacy
import
legacy_index
from
scheduler
import
sched_func
from
mail
import
notify_mods
,
notify_admins
mod_endpoints
=
[]
...
...
@@ -124,7 +124,7 @@ def handle_not_found(e=None):
@
app
.
errorhandler
(
Exception
)
def
handle_internal_error
(
e
):
traceback
.
print_exc
()
notify_admins
(
'exception'
,
traceback
=
traceback
.
format_exc
())
notify_admins
(
'
endpoint_
exception'
,
traceback
=
traceback
.
format_exc
())
return
render_template
(
'500.html'
),
500
@
sched_func
(
5
*
60
,
firstdelay
=
0
)
...
...
templates/mails/exception.body
→
templates/mails/
endpoint_
exception.body
View file @
9c7bbbdd
File moved
templates/mails/exception.subject
→
templates/mails/
endpoint_
exception.subject
View file @
9c7bbbdd
File moved
templates/mails/scheduler_exception.body
0 → 100644
View file @
9c7bbbdd
Function: {{ name }}
Hostname: {{ gethostname() }}
{{ traceback }}
templates/mails/scheduler_exception.subject
0 → 100644
View file @
9c7bbbdd
Exception in scheduler function "{{ name }}"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment