summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTianci Hu Marrero <69414708+iggeehu@users.noreply.github.com>2023-02-27 04:10:39 -0500
committerGitHub <noreply@github.com>2023-02-27 16:10:39 +0700
commit1fa6ec1055c5befa0e9c7c5bb74ebaa99eda5883 (patch)
tree1a675974522c28ab9a983327f1cb96c7db1cdba4
parent08d8f7c30cc705310d0004ca02a7778ad1ca466a (diff)
downloadrq-1fa6ec1055c5befa0e9c7c5bb74ebaa99eda5883.tar.gz
(Docs) Updated patterns - heroku (#1841)
* Update index.md * Update index.md * Update index.md import herokuWorker instead.
-rw-r--r--docs/patterns/index.md21
1 files changed, 11 insertions, 10 deletions
diff --git a/docs/patterns/index.md b/docs/patterns/index.md
index 23f67a4..512918e 100644
--- a/docs/patterns/index.md
+++ b/docs/patterns/index.md
@@ -12,24 +12,24 @@ To setup RQ on [Heroku][1], first add it to your
rq>=0.13
Create a file called `run-worker.py` with the following content (assuming you
-are using [Redis To Go][2] with Heroku):
+are using [Heroku Data For Redis][2] with Heroku):
```python
import os
-import urlparse
+import redis
from redis import Redis
from rq import Queue, Connection
from rq.worker import HerokuWorker as Worker
+
listen = ['high', 'default', 'low']
-redis_url = os.getenv('REDISTOGO_URL')
+redis_url = os.getenv('REDIS_URL')
if not redis_url:
- raise RuntimeError('Set up Redis To Go first.')
-
-urlparse.uses_netloc.append('redis')
-url = urlparse.urlparse(redis_url)
-conn = Redis(host=url.hostname, port=url.port, db=0, password=url.password)
+ raise RuntimeError("Set up Heroku Data For Redis first, \
+ make sure the its config var is named 'REDIS_URL'.")
+
+conn = redis.from_url(redis_url)
if __name__ == '__main__':
with Connection(conn):
@@ -47,7 +47,7 @@ Now, all you have to do is spin up a worker:
$ heroku scale worker=1
```
-If you are using [Heroku Redis][5]) you might need to change the Redis connection as follows:
+If the from_url function fails to parse your credentials, you might need to do so manually:
```console
conn = redis.Redis(
@@ -58,6 +58,7 @@ conn = redis.Redis(
ssl_cert_reqs=None
)
```
+The details are from the 'settings' page of your Redis add-on on the Heroku dashboard.
and for using the cli:
@@ -90,7 +91,7 @@ force stdin, stdout and stderr to be totally unbuffered):
worker: python -u run-worker.py
[1]: https://heroku.com
-[2]: https://devcenter.heroku.com/articles/redistogo
+[2]: https://devcenter.heroku.com/articles/heroku-redis
[3]: https://github.com/ddollar/foreman
[4]: https://github.com/ddollar/foreman/wiki/Missing-Output
[5]: https://elements.heroku.com/addons/heroku-redis