How to run Daphne Server (Django Channels) & workers in the background?

梦想与她 提交于 2019-12-23 03:29:09

问题


I have installed Django Channels. I am trying to run the following commands to run Daphne server and a worker.

> daphne chat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2
> python manage.py runworker -v2

But each command opens up a live terminal showing logs. I just want to run them as background processes. Can anyone show me how to do this?


回答1:


For these type of tasks, you should use supervisor.




回答2:


At the moment nohup & is working alright for me. The following commands run the processes in the background.

> sudo nohup daphne MyProject.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2 &
> sudo nohup python manage.py runworker -v2 &

kill -9 [pid] should help kill them when needed.




回答3:


You can use circus, supervisor or at least systemd.

Read this article to run easy and fast.



来源:https://stackoverflow.com/questions/37339393/how-to-run-daphne-server-django-channels-workers-in-the-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!