Here are two basic examples of almost the same uWSGI configuration to run a Django project; one is configured via an ini configuration file and the other is configured via a command line argument.
This does not represent a production-ready example, but can be used as a starting point for the configuration.
Setup for this example:
# create dir for virtualenv and activate
mkdir envs/
virtualenv envs/runrun/
. ./envs/runrun/bin/activate
# create dir for project codebase
mkdir proj/
# install some django deps
pip install django uwsgi whitenose
# create a new django project
cd proj/
django-admin startproject runrun
cd runrun/
# Add to or modify django settings.py to setup static file serving with Whitenoise.
# Note: for prod environments, staticfiles can be served via Nginx.
# settings.py
MIDDLEWARE_CLASSES = [
....
'whitenoise.middleware.WhiteNoiseMiddleware',
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Create the config file
$ cat run.ini
[uwsgi]
module = runrun.wsgi:application
virtualenv = ../../envs/runrun/
env = DJANGO_SETTINGS_MODULE=runrun.settings
env = PYTHONPATH="$PYTHONPATH:./runrun/"
master = true
processes = 5
enable-threads = true
max-requests = 5000
harakiri = 20
vacuum = true
http = :7777
stats = 127.0.0.1:9191
Execute config
uwsgi --ini run.ini
Or create a shell script
$ cat run.sh
uwsgi --module=runrun.wsgi:application \
-H ../../envs/runrun/ \
--env DJANGO_SETTINGS_MODULE=runrun.settings \
--env PYTHONPATH="$PYTHONPATH:./runrun/" \
--master \
--processes=5 \
--max-requests=5000 \
--harakiri=20 \
--vacuum \
--http=127.0.0.1:7777 \
--stats 127.0.0.1:9191
Execute the shell script:
./run.sh
Command line reference
--env = set environment variable
--max-requests = reload workers after the specified amount of managed requests
--https2 = http2.0
--http = run in http mode
--socket = use in place of http if using an Nginx reverse proxy
--vacuum = clear environment on exit; try to remove all of the generated file/sockets
--uid = setuid to the specified user/uid
--gid = setgid to the specified group/gid
--stats = run a stats server
--H, --virtualenv = virtualenv dir
--processes = num of worker processes
--module = python module entry point
This does not represent a production-ready example, but can be used as a starting point for the configuration.
Setup for this example:
# create dir for virtualenv and activate
mkdir envs/
virtualenv envs/runrun/
. ./envs/runrun/bin/activate
# create dir for project codebase
mkdir proj/
# install some django deps
pip install django uwsgi whitenose
# create a new django project
cd proj/
django-admin startproject runrun
cd runrun/
# Add to or modify django settings.py to setup static file serving with Whitenoise.
# Note: for prod environments, staticfiles can be served via Nginx.
# settings.py
MIDDLEWARE_CLASSES = [
....
'whitenoise.middleware.WhiteNoiseMiddleware',
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
Create the config file
$ cat run.ini
[uwsgi]
module = runrun.wsgi:application
virtualenv = ../../envs/runrun/
env = DJANGO_SETTINGS_MODULE=runrun.settings
env = PYTHONPATH="$PYTHONPATH:./runrun/"
master = true
processes = 5
enable-threads = true
max-requests = 5000
harakiri = 20
vacuum = true
http = :7777
stats = 127.0.0.1:9191
Execute config
uwsgi --ini run.ini
Or create a shell script
$ cat run.sh
uwsgi --module=runrun.wsgi:application \
-H ../../envs/runrun/ \
--env DJANGO_SETTINGS_MODULE=runrun.settings \
--env PYTHONPATH="$PYTHONPATH:./runrun/" \
--master \
--processes=5 \
--max-requests=5000 \
--harakiri=20 \
--vacuum \
--http=127.0.0.1:7777 \
--stats 127.0.0.1:9191
Execute the shell script:
./run.sh
Command line reference
--env = set environment variable
--max-requests = reload workers after the specified amount of managed requests
--https2 = http2.0
--http = run in http mode
--socket = use in place of http if using an Nginx reverse proxy
--vacuum = clear environment on exit; try to remove all of the generated file/sockets
--uid = setuid to the specified user/uid
--gid = setgid to the specified group/gid
--stats = run a stats server
--H, --virtualenv = virtualenv dir
--processes = num of worker processes
--module = python module entry point
The King Casino Company - Ventureberg
ReplyDeleteIt was born in 1934. The Company offers luxury hotels, If you don't have a poker room in your ventureberg.com/ house, then you'll jancasino.com find septcasino.com a 출장마사지 poker casinosites.one room in the