Django server killed frequently

ghz 1years ago ⋅ 1424 views

Question

I'm developing a Django project and testing it on a dedicated server. The project is running on:

  • django 1.9.6
  • virtualenv
  • python 2.7
  • cx_Oracle 5.2.1

Running

python manage.py runserver 192.168.30.17:8080 &

all goes well. Project running and with ps aux I get, for example:

root      8437  0.0  0.9 461108 39036 pts/0    S    15:17   0:00 python manage.py runserver 192.168.30.17:8080
root      8861  3.5  1.5 1319364 64232 pts/0   Sl   15:24   0:14 /new_esmart/esmart_env/bin/python manage.py runserver 192.168.30.17:8080

THE PROBLEM: Frequently server goes down with no error showed on shell. I simply receive: Killed

How can I retrieve more information to find the cause of this killing?

NOTE : No gunicorn et similia solution right now. I have to use django server for the next hours

Temporary solution

A script that respawns the server when killed

until python manage.py runserver 192.168.30.17:8080; do
   echo "Server Django crashed with exit code $. Respawning ...">&2
   sleep 2
done

Answer

From the documentation on the django development server https://docs.djangoproject.com/en/1.10/ref/django-admin/

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

Of course it get's killed frequently, it's not designed to be kept running for long hours. Set up one of the standard solutions such as gunicorn+nginx or apache+uswgi etc.