Sha*_*dra 5 nginx flask uwsgi python-3.x plotly-dash
我 \xe2\x80\x99m 是 Flask 和部署过程的新手\n我的 dash.py 设置如下
\n\nserver = flask.Flask(__name__)\napp = dash.Dash(__name__, server=server)\nRun Code Online (Sandbox Code Playgroud)\n\n和我的 nginx 文件
\n\nserver {\nlisten 80;\nserver_name localhost;\ncharset utf-8;\nclient_max_body_size 75M;\n\nlocation / {try_files $uri @yourapplication; }\nlocation @yourapplication {\n include uwsgi_params;\n uwsgi_pass unix:/var/www/School-Dashboard/dash_clean.sock;\n}\n}\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\xa6but i\xe2\x80\x99m 不确定我必须在 wsgi ini 文件中设置模块参数。
\n\n[uwsgi]\n#application's base folder\nbase = /var/www/School-Dahboard\n\n#python module to import\nmodule = dash_clean:app #?????? WHAT DO I DO HERE\n\n#home = %(base)/venv\npythonpath = %(base)\n\n#socket file's location\nsocket = /var/www/School-Dashboard/dash_clean.sock\n\n#permissions for the socket file\nchmod-socket = 660\n\n\n#location of log files\nlogto = /var/log/uwsgi/%n.log\nRun Code Online (Sandbox Code Playgroud)\n\n由于我的 uwsgi 文件,我不断收到错误的网关错误。
\n\n这是来自 uwsgi 的日志。
\n\nStarting uWSGI 2.0.17.1 (64bit) on [Mon Nov 5 12:47:42 2018] ***\ncompiled with version: 5.4.0 20160609 on 03 November 2018 06:53:29\nos: Linux-4.15.0-36-generic #39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018\nnodename: xxxxxxxx\nmachine: x86_64\nclock source: unix\ndetected number of CPU cores: 4\ncurrent working directory: /var/www/School-Dashboard\ndetected binary path: /home/concent/.local/bin/uwsgi\n!!! no internal routing support, rebuild with pcre support !!!\n*** WARNING: you are running uWSGI without its master process manager ***\nyour processes number limit is 31145\nyour memory page size is 4096 bytes\ndetected max file descriptor number: 1024\nlock engine: pthread robust mutexes\nthunder lock: disabled (you can enable it with --thunder-lock)\nuwsgi socket 0 bound to UNIX address /var/www/School-Dashboard/dash_clean.sock fd 3\nPython version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]\n*** Python threads support is disabled. You can enable it with --enable-threads ***\nPython main interpreter initialized at 0x22b9330\nyour server socket listen backlog is limited to 100 connections\nyour mercy for graceful operations on workers is 60 seconds\nmapped 72920 bytes (71 KB) for 1 cores\n*** Operational MODE: single process ***\nadded /var/www/School-Dahboard to pythonpath.\nWSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x22b9330 pid: 20070 (default app)\n*** uWSGI is running in multiple interpreter mode ***\nspawned uWSGI worker 1 (and the only) (pid: 20070, cores: 1)\nRun Code Online (Sandbox Code Playgroud)\n
所以我已经将 nginx 设置为这样......
server {
server_name 0.0.0.0;
listen 80;
root /home/ubuntu/school_dashboard;
client_max_body_size 200M;
include /etc/nginx/default.d/*.conf;
location /dependencies {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_pass http://0.0.0.0:5005;
#index wsgi.py
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/school_dashboard/dependencies/urlgen.sock;
}
}
Run Code Online (Sandbox Code Playgroud)
我的 uwsgi 文件为......
[uwsgi]
module = dash_clean:server
master = true
processes = 5
socket = dashboard.sock
chmod-socket = 660
vacuum = true
die-on-term = true
Run Code Online (Sandbox Code Playgroud)
我只需更改模块参数
| 归档时间: |
|
| 查看次数: |
4005 次 |
| 最近记录: |