Channels: python manage.py runworker not working in Heroku

Created on 6 Feb 2018  路  3Comments  路  Source: django/channels

I have followed the Channels and heroku tutorial on adding channels to my app. The app is generally working well, but one of the issues is that while the web dyno are running well, I'm not able to scale up the worker dyno.
Apologies if this isn't the right place to ask, It seems to that this has already been referenced here but I'm confused as to how to proceed as its working in development but not production.

Here is the procfile:
web: daphne server.asgi:application --port $PORT --bind 0.0.0.0 -v2 worker: python manage.py runworker -v2
Here is the error which I am getting in Heroku:

2018-02-06T13:41:37.063337+00:00 heroku[worker.1]: Starting process with command `python manage.py runworker -v2`
2018-02-06T13:41:37.636207+00:00 heroku[worker.1]: State changed from starting to up
2018-02-06T13:41:40.852555+00:00 app[worker.1]: Traceback (most recent call last):
2018-02-06T13:41:40.852586+00:00 app[worker.1]:   File "manage.py", line 39, in <module>
2018-02-06T13:41:40.852706+00:00 app[worker.1]:     execute_from_command_line(sys.argv)
2018-02-06T13:41:40.852711+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
2018-02-06T13:41:40.852933+00:00 app[worker.1]:     utility.execute()
2018-02-06T13:41:40.852937+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
2018-02-06T13:41:40.853144+00:00 app[worker.1]:     django.setup()
2018-02-06T13:41:40.853148+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
2018-02-06T13:41:40.853266+00:00 app[worker.1]:     apps.populate(settings.INSTALLED_APPS)
2018-02-06T13:41:40.853270+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
2018-02-06T13:41:40.853395+00:00 app[worker.1]:     app_config = AppConfig.create(entry)
2018-02-06T13:41:40.853400+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 120, in create
2018-02-06T13:41:40.853523+00:00 app[worker.1]:     mod = import_module(mod_path)
2018-02-06T13:41:40.853526+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-02-06T13:41:40.853712+00:00 app[worker.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2018-02-06T13:41:40.853715+00:00 app[worker.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2018-02-06T13:41:40.853862+00:00 app[worker.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2018-02-06T13:41:40.853929+00:00 app[worker.1]:   File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
2018-02-06T13:41:40.854025+00:00 app[worker.1]:   File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
2018-02-06T13:41:40.854107+00:00 app[worker.1]:   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2018-02-06T13:41:40.854212+00:00 app[worker.1]:   File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
2018-02-06T13:41:40.854312+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/channels/apps.py", line 6, in <module>
2018-02-06T13:41:40.854416+00:00 app[worker.1]:     import daphne.server  # noqa
2018-02-06T13:41:40.854419+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/daphne/server.py", line 3, in <module>
2018-02-06T13:41:40.854526+00:00 app[worker.1]:     asyncioreactor.install()  # isort:skip
2018-02-06T13:41:40.854530+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/twisted/internet/asyncioreactor.py", line 322, in install
2018-02-06T13:41:40.854732+00:00 app[worker.1]:     installReactor(reactor)
2018-02-06T13:41:40.854736+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/twisted/internet/main.py", line 32, in installReactor
2018-02-06T13:41:40.854861+00:00 app[worker.1]:     raise error.ReactorAlreadyInstalledError("reactor already installed")
2018-02-06T13:41:40.854877+00:00 app[worker.1]: twisted.internet.error.ReactorAlreadyInstalledError: reactor already installed
2018-02-06T13:41:41.024179+00:00 heroku[worker.1]: Process exited with status 1
2018-02-06T13:41:41.063480+00:00 heroku[worker.1]: State changed from up to crashed

Most helpful comment

runworker is no longer needed for normal hosting in Channels 2, so there is no need to run it.

The error you have is because you have an old version of Daphne and probably have raven installed. Update Daphne and it should go away.

All 3 comments

runworker is no longer needed for normal hosting in Channels 2, so there is no need to run it.

The error you have is because you have an old version of Daphne and probably have raven installed. Update Daphne and it should go away.

@andrewgodwin Does this mean I can delete my worker dyno i created on heroku

@andrewgodwin sorry, heroku deleted it once i removed it from my Procfile. Thanks

Was this page helpful?
0 / 5 - 0 ratings