add configs: nginx, supervisor, gunicorn
This commit is contained in:
parent
4f93cc0956
commit
379eb33ae4
36
docs/examples/nginx_gunicorn/gunicorn_start
Executable file
36
docs/examples/nginx_gunicorn/gunicorn_start
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
export MPLCONFIGDIR="/srv/nsupdate/run/"
|
||||
|
||||
NAME="nsupdate.info" # Name of the application
|
||||
DJANGODIR=/srv/nsupdate/nsupdate/nsupdate # Django project directory
|
||||
SOCKFILE=/srv/nsupdate/run/gunicorn.sock # communication socket
|
||||
PIDFILE=/srv/nsupdate/run/gunicorn.pid
|
||||
USER=www-data # the user to run as
|
||||
GROUP=www-data # the group to run as
|
||||
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
|
||||
DJANGO_SETTINGS_MODULE=nsupdate.settings # which settings file should Django use
|
||||
DJANGO_WSGI_MODULE=nsupdate.wsgi # WSGI module name
|
||||
|
||||
echo "Starting $NAME"
|
||||
|
||||
# Activate the virtual environment
|
||||
cd $DJANGODIR
|
||||
source /srv/nsupdate/bin/activate
|
||||
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
|
||||
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
|
||||
|
||||
# Create the run directory if it doesn't exist
|
||||
RUNDIR=$(dirname $SOCKFILE)
|
||||
test -d $RUNDIR || mkdir -p $RUNDIR
|
||||
|
||||
# Start your Django Unicorn
|
||||
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
|
||||
exec /srv/nsupdate/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
|
||||
--name $NAME \
|
||||
--workers $NUM_WORKERS \
|
||||
--user=$USER --group=$GROUP \
|
||||
--log-level=debug \
|
||||
--bind=unix:$SOCKFILE \
|
||||
--pid $PIDFILE
|
||||
|
49
docs/examples/nginx_gunicorn/nginx.conf
Normal file
49
docs/examples/nginx_gunicorn/nginx.conf
Normal file
@ -0,0 +1,49 @@
|
||||
upstream nsupdate_server {
|
||||
server unix:/srv/nsupdate/run/gunicorn.sock fail_timeout=0;
|
||||
}
|
||||
|
||||
server {
|
||||
listen :80;
|
||||
server_name nsupdate.info;
|
||||
return 301 http://www.nsupdate.info$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
|
||||
listen :80;
|
||||
listen [::]:80;
|
||||
server_name nsupdate.info ipv4.nsupdate.info ipv6.nsupdate.info;
|
||||
server_tokens off;
|
||||
|
||||
client_max_body_size 4G;
|
||||
|
||||
access_log /srv/nsupdate/logs/nginx-access.log;
|
||||
error_log /srv/nsupdate/logs/nginx-error.log;
|
||||
|
||||
location /favicon.png {
|
||||
alias /srv/nsupdate/static/favicon.png;
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /srv/nsupdate/static/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# when doing https
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
|
||||
if (!-f $request_filename) {
|
||||
proxy_pass http://nsupdate_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
# Error pages
|
||||
error_page 500 502 503 504 /500.html;
|
||||
location = /500.html {
|
||||
root /srv/nsupdate/static/;
|
||||
}
|
||||
}
|
5
docs/examples/nginx_gunicorn/supervisor.conf
Normal file
5
docs/examples/nginx_gunicorn/supervisor.conf
Normal file
@ -0,0 +1,5 @@
|
||||
[program:nsupdate.info]
|
||||
command = /srv/nsupdate/bin/gunicorn_start ; Command to start app
|
||||
user = www-data ; User to run as
|
||||
stdout_logfile = /srv/nsupdate/logs/gunicorn_supervisor.log ; Where to write log messages
|
||||
redirect_stderr = true ; Save stderr in the same log
|
Loading…
x
Reference in New Issue
Block a user