mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 13:37:56 +08:00
putting back support for backwards compatibility
This commit is contained in:
@@ -25,7 +25,7 @@ import signing
|
||||
import tasks
|
||||
|
||||
from django_q.compat import range
|
||||
from django_q.conf import Conf, logger, psutil, get_ppid, error_reporter
|
||||
from django_q.conf import Conf, logger, psutil, get_ppid, error_reporter, rollbar
|
||||
from django_q.models import Task, Success, Schedule
|
||||
from django_q.status import Stat, Status
|
||||
from django_q.brokers import get_broker
|
||||
@@ -367,6 +367,8 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
|
||||
result = (e, False)
|
||||
if error_reporter:
|
||||
error_reporter.report()
|
||||
if rollbar:
|
||||
rollbar.report_exc_info()
|
||||
# We're still going
|
||||
if not result:
|
||||
db.close_old_connections()
|
||||
@@ -382,6 +384,8 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
|
||||
result = ('{}'.format(e), False)
|
||||
if error_reporter:
|
||||
error_reporter.report()
|
||||
if rollbar:
|
||||
rollbar.report_exc_info()
|
||||
# Process result
|
||||
task['result'] = result[0]
|
||||
task['success'] = result[1]
|
||||
|
||||
@@ -142,6 +142,9 @@ class Conf(object):
|
||||
# The redis stats key
|
||||
Q_STAT = 'django_q:{}:cluster'.format(PREFIX)
|
||||
|
||||
# Optional rollbar key
|
||||
ROLLBAR = conf.get('rollbar', {})
|
||||
|
||||
# Optional error reporting setup
|
||||
ERROR_REPORTER = conf.get('error_reporter', {})
|
||||
|
||||
@@ -179,6 +182,19 @@ if not logger.handlers:
|
||||
logger.addHandler(handler)
|
||||
|
||||
|
||||
# rollbar
|
||||
if Conf.ROLLBAR:
|
||||
rollbar_conf = deepcopy(Conf.ROLLBAR)
|
||||
try:
|
||||
import rollbar
|
||||
rollbar.init(rollbar_conf.pop('access_token'), environment=rollbar_conf.pop('environment'), **rollbar_conf)
|
||||
except ImportError:
|
||||
rollbar = None
|
||||
|
||||
else:
|
||||
rollbar = None
|
||||
|
||||
|
||||
# Error Reporting Interface
|
||||
class ErrorReporter(object):
|
||||
|
||||
|
||||
@@ -373,20 +373,24 @@ To enable installed error reporters, you must provide the configuration settings
|
||||
|
||||
For more information on error reporters and developing error reporting plugins for Django Q, see :doc:`errors<errors>`.
|
||||
|
||||
.. rollbar
|
||||
.. ~~~~~~~
|
||||
.. You can redirect worker exceptions directly to your `Rollbar <https://rollbar.com/>`__ dashboard by installing the python notifier with ``pip install rollbar`` and adding this configuration dictionary to your config::
|
||||
rollbar
|
||||
~~~~~~~
|
||||
You can redirect worker exceptions directly to your `Rollbar <https://rollbar.com/>`__ dashboard by installing the python notifier with ``pip install rollbar`` and adding this configuration dictionary to your config::
|
||||
|
||||
.. # rollbar config
|
||||
.. Q_CLUSTER = {
|
||||
.. 'rollbar': {
|
||||
.. 'access_token': '32we33a92a5224jiww8982',
|
||||
.. 'environment': 'Django-Q'
|
||||
.. }
|
||||
.. }
|
||||
# rollbar config
|
||||
Q_CLUSTER = {
|
||||
'rollbar': {
|
||||
'access_token': '32we33a92a5224jiww8982',
|
||||
'environment': 'Django-Q'
|
||||
}
|
||||
}
|
||||
|
||||
.. Please check the Pyrollbar `configuration reference <https://github.com/rollbar/pyrollbar#configuration-reference>`__ for more options.
|
||||
.. Note that you will need a `Rollbar <https://rollbar.com/>`__ account and access token to use this feature.
|
||||
Please check the Pyrollbar `configuration reference <https://github.com/rollbar/pyrollbar#configuration-reference>`__ for more options.
|
||||
Note that you will need a `Rollbar <https://rollbar.com/>`__ account and access token to use this feature.
|
||||
|
||||
|
||||
.. note::
|
||||
The ``rollbar`` setting is included for backwards compatibility, for those who utilized rollbar configuration before the ``error_reporter`` interface was introduced. Note that Rollbar support can be configured either via the ``rollbar`` setting, or via the ``django-q-rollbar`` package and enabled via the ``error_reporter`` setting above.
|
||||
|
||||
cpu_affinity
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user