Using Daphne without altering nginx config on Google App Engine

539 views
Skip to first unread message

Rahul Arora

unread,
Jan 18, 2020, 9:11:46 AM1/18/20
to Django users
Hi all,

I'm trying to switch from gunicorn to Daphne for my Django app on GAE Flex, since I need to use Django Channels. Previously the site worked fine with gunicorn as entrypoint (in the app.yaml file). I just replaced it with daphne so my yamlfile looks like this:

runtime: python
env: flex

runtime_config:
  python_version: 3

entrypoint: daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application

I've already made a .asgi file next to my .wsgi file and declared an application there.

In requirements.txt I've ensured the daphne(2.4.1) and asgiref(3.2.3) packages are the latest versions.

Finally when I do 'gcloud app deploy', deployment appears to happen smoothly and in the build logs I can see daphne starting:


Step #1: Step 9/9 : CMD exec daphne -b 0.0.0.0 -p 8001 my_project_name.asgi:application Step #1: ---> Running in c6f3762a5ce2

But when I go to the site, I'm seeing a 502 Bad Gateway error on the site, with "nginx" in the next line.

Is there a way to deploy Daphne without going into nginx configurations etc? I'm using an app engine only because I wanted to avoid doing micro-level tweaks on a cloud machine.

Thanks,
Rahul.

Integr@te System

unread,
Jan 19, 2020, 12:41:09 AM1/19/20
to django...@googlegroups.com
Hi Rahu,

Check chennel_layers setting as a sample in this doc for more helpful




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dfb79af0-663c-4581-8fab-f06d2281d875%40googlegroups.com.

Rahul Arora

unread,
Jan 20, 2020, 12:07:32 AM1/20/20
to Django users
Thanks for your reply. Is there really no way of using daphne without altering nginx/supervisord config like we use gunicorn?

If not, I have some questions based on my efforts so far, please. I will be grateful for your attention to these. Apologies if they're silly questions since I'm a beginner:
1. If I reconfigure nginx and supervisord, how should I make sure the conf files get picked up by GAE? Should I add something to the app.yaml file to point to the nginx-app.conf file in the root folder? Should I also change my runtime declaration to custom, or leave it as python? I find that whenever I add an nginx-app.conf file in the root folder the build times out and I get an Error[4] from gcloud app deploy. Otherwise the build completes fully.
2. If I am starting a Unix socket for Daphne in the supervisord config file, what happens to the entrypoint delaration in the ap.yaml file? Do I delete that?
3. How do I know what path I should use in the command: "daphne -u /run/daphne/daphne%(process_num)d.sock". Also, what is process_num?
4. The new conf files (for nginx and supervisord in the documentation shared by you) refer to localhost:8000 - should I change this? What is the TCP socket used by nginx backend?
5. How can I do things like updating supervisor, "sudo service nginx reload" etc on the GAE PaaS platform since I'm not operating the instance directly? Or is this not necessary since I'm creating a whole new build each time?

Sorry for the barrage and thanks in advance,
Rahul.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Integr@te System

unread,
Jan 20, 2020, 2:14:35 AM1/20/20
to django...@googlegroups.com
Hi Rahu,

Plz scrutinize  more info to differ, combine and select right one for your case.



To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/663c1f9c-9bdc-4da1-95d6-269c13c6c86b%40googlegroups.com.

Sai Santhosh

unread,
Jan 20, 2020, 7:34:44 AM1/20/20
to django...@googlegroups.com

Rahul Arora

unread,
Jan 20, 2020, 9:42:25 AM1/20/20
to Django users
Thanks but this is not a valid or useful comparison since GAE is a PaaS service whereas Nginx is a proxy server. In fact GAE itself uses Nginx which is why I'm getting the error from Nginx despite not configuring it myself.

Rahul.

Integr@te System

unread,
Jan 20, 2020, 10:44:17 AM1/20/20
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages