1

I am trying to host Django application in CloudFoundry. I am able to host the application if I use external package gunicorn. But with Django's inbuilt runserver, the application is not getting started.

The Procfile content with Gunicorn is:

web: gunicorn 
dcms.wsgi:application

The result with this Procfile:

Application is started and can be seen working successfully on the URL.

The Procfile content with django's inbuilt runserver is:

web: python manage.py runserver 0.0.0.0:8080

The result with this Procfile:

Waiting for app to start... Start unsuccessful

So, Would like to know the difference between the two. And want to make it work using runserver without using external package.

Yugandhar Chaudhari
  • 3,831
  • 3
  • 24
  • 40
richa verma
  • 247
  • 2
  • 13
  • 1
    Not an answer to your question but why would you want to use the development server for production if you were able to get Gunicorn running? – Selcuk Oct 16 '19 at 05:56
  • Gunicorn is one of the best known application servers, not sure if using Django's development server, which is not designed for production, would be more compliant. Besides, what is the definition of an external package? You are using Django, which is an external package too. **Edit:** The OP seems to have deleted their comment. – Selcuk Oct 16 '19 at 06:06
  • I am using the term external package because I need to add Gunicorn in requirement.txt files where we mention what all packages are required for the Application. I have less knowledge on Gunicorn and Django's server. I wanted to know about that only and why it was working with one command and not with other – richa verma Oct 16 '19 at 06:17
  • Fair enough, my comment was slightly off-topic, but good advice anyway. – Selcuk Oct 16 '19 at 06:21
  • I imagine the reason is that CloudFoundry expects the web process to bind to port 80. – Daniel Roseman Oct 16 '19 at 06:35
  • @DanielRoseman If they are using the Python buildpack, it expects the Python app to listen to port 8080: https://docs.cloudfoundry.org/buildpacks/python/index.html#run-the-web-server – Selcuk Oct 16 '19 at 06:38
  • Not sure but can you try like `web: python /manage.py runserver 0.0.0.0:8080`.. full path for `manage.py`? – anuragal Oct 16 '19 at 06:42
  • My manage.py is in root folder itself, then also? – richa verma Oct 16 '19 at 08:00
  • When I use Gunicorn, What is internally happening Cloud foundry and Gunicorn. As Gunicorn is a production server, is my code going outside Cloud Foundry? – richa verma Oct 16 '19 at 09:08
  • Either option should work. After your app fails to start you need to run `cf logs --recent` and see why it failed to start. It could be for any number of reasons. Post what you find. – Daniel Mikusa Oct 17 '19 at 02:55
  • python manage.py runserver 0.0.0.0:8080 is also working now, I don't know the reason. With this command it was not working earlier. Now when I used this command to see the logs, the application is hosted and is up. – richa verma Oct 19 '19 at 08:21

0 Answers0