Skip to content

Commit

Permalink
adding redis queues worker
Browse files Browse the repository at this point in the history
  • Loading branch information
imkevinxu committed Sep 2, 2014
1 parent 39c2034 commit aba0b5b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: gunicorn {{ project_name }}.config.wsgi --workers $WEB_CONCURRENCY
worker: python -u {{ project_name }}/worker.py
1 change: 1 addition & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: django-admin.py runserver_plus
worker: python -u {{ project_name }}/worker.py
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ base.txt
- [django-redis 3.7.1](https://django-redis.readthedocs.org/en/latest/) - enables redis cacheing
- [psycopg2 2.5.3](http://pythonhosted.org//psycopg2/) - PostgreSQL adapter
- [pytz 2014.4](http://pytz.sourceforge.net/) - world timezone definitions
- [rq 0.4.6](http://python-rq.org/) - background tasks using redis as queue
- [static 1.0.2](https://github.com/lukearno/static) - serves static and dynamic content

local.txt
Expand Down
15 changes: 15 additions & 0 deletions project_name/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import redis

from rq import Worker, Queue, Connection

listen = ['high', 'default', 'low']

redis_url = os.getenv('REDISCLOUD_URL', 'redis://localhost:6379')

conn = redis.from_url(redis_url)

if __name__ == '__main__':
with Connection(conn):
worker = Worker(map(Queue, listen))
worker.work()
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ django-model-utils==2.2
django-redis==3.7.1
psycopg2==2.5.3
pytz==2014.4
rq==0.4.6
static==1.0.2

0 comments on commit aba0b5b

Please sign in to comment.