问题
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