lincolnloop / django-production

production settings for Django
MIT License
91 stars 3 forks source link

Windows support #1

Open ipmb opened 1 year ago

ipmb commented 1 year ago

I'd like to support Windows (gunicorn doesn't work there), but I don't have any experience running Django on it.

How are folks deploying Django projects to Windows? Is waitress the app server of choice or something else?

kokhoor commented 1 year ago

I have deployed django using waitress + WhiteNoise running as a Windows Service, but it hasn't really undergone any stress / performance testing, as the no of users are still quite low, but we found the performance reasonable, but more importantly, the setup was simple. Below is a snippet if it helps (may not run as it is as I had taken off some bits customized for our folders).

import os

from waitress.server import create_server
from whitenoise import WhiteNoise

from [YOUR_SETTINGS_APP_FOLDER].wsgi import application

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
static_folder = os.path.join(BASE_DIR, 'static')

application = WhiteNoise(application, root=static_folder)
application.add_files(static_folder)
server = create_server(application, host='0.0.0.0', port=80)
server.run()