Search code examples
pythondjangoproductionchanneldaphne

How to update python code and see changes live using daphne, Django Channels?


I just made some changes over 1 python file in my production server, then tested the changes using "runserver" command:

python3 manage.py runserver 0.0.0.0:3031

The changes are done correctly, then I try to see the same changes in production but using websockets with Django Channels, but the result seems to be that the server is running the old code.

nohup daphne -b 0.0.0.0 -p 3031 asgi:channel_layer &
nohup python manage.py runworker &

What could be the reason, is there any code cache?, what can I do to refresh the code?


Solution

  • I found that the solution was to kill all "python runworkers" processes, and then restart the server with daphne and runworker.

    sudo pkill python
    nohup daphne -b 0.0.0.0 -p 3031 asgi:channel_layer &
    nohup python manage.py runworker &