diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..4aa61bf --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,19 @@ +import os +import multiprocessing + +bind = '0.0.0.0:8000' +backlog = 512 +chdir = os.path.dirname(os.path.abspath(__file__)) +timeout = 30 +worker_class = 'sync' + +workers = multiprocessing.cpu_count() * 2 + 1 +threads = 2 +loglevel = 'info' +access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"' + +if not os.path.exists('logs'): + os.mkdir('logs') + +accesslog = os.path.join(chdir, "logs/gunicorn_access.log") +errorlog = os.path.join(chdir, "logs/gunicorn_error.log") diff --git a/pear-nginx.conf b/pear-nginx.conf new file mode 100644 index 0000000..10cb659 --- /dev/null +++ b/pear-nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80 default_server; + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + location / { + proxy_pass http://127.0.0.1:8000; # 转发的地址,即Gunicorn运行的地址 + proxy_redirect off; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/pear-supervisor.conf b/pear-supervisor.conf new file mode 100644 index 0000000..4c8fb6e --- /dev/null +++ b/pear-supervisor.conf @@ -0,0 +1,7 @@ +[program:pear] +command=bash /home/ubuntu/pear-admin-flask/start.sh +user=root +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..a852590 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +cd /home/ubuntu/pear-admin-flask +source venv/bin/activate +exec gunicorn -c gunicorn.conf.py "applications:create_app()"