diff options
author | Donald Stufft <donald@stufft.io> | 2013-07-24 23:45:24 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-07-24 23:45:24 -0400 |
commit | edb52be7e3da1c9aa19a3b0ca3aa850491d2d4ba (patch) | |
tree | b491ac7fac73a4655e71dae6608fbf772a5cf4fb | |
parent | 063ff638817f3732d088f1794a4dfc3ac15e7dfb (diff) | |
download | decorator-edb52be7e3da1c9aa19a3b0ca3aa850491d2d4ba.tar.gz |
Send errors from the RQ worker to Sentry
-rwxr-xr-x | tools/worker.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/worker.py b/tools/worker.py index 133558e..9cad795 100755 --- a/tools/worker.py +++ b/tools/worker.py @@ -3,8 +3,10 @@ import os import os.path import sys +import raven import redis import rq +import rq.contrib.sentry # Workaround current bug in docutils: # http://permalink.gmane.org/gmane.text.docutils.devel/6324 @@ -16,14 +18,22 @@ sys.path = [root] + sys.path import config - conf = config.Config(os.environ.get("PYPI_CONFIG", "/data/pypi/config.ini")) redis_conn = redis.Redis.from_url(conf.redis_url) +# Create our queues if sys.argv[1:]: queues = [rq.Queue(name, connection=redis_conn) for name in sys.argv[1:]] else: queues = [rq.Queue(connection=redis_conn)] +# Create our Worker worker = rq.Worker(queues, connection=redis_conn) + +# Create our Sentry Client +if conf.sentry_dsn: + raven_client = raven.Client(conf.sentry_dsn) + rq.contrib.sentry.register_sentry(raven_client, worker) + +# Run our worker, fetching jobs from the queue worker.work() |