uWSGI +nginx 设置 - Dash (Plotly) 部署
uWSGI +nginx setup - Dash (Plotly) Deployment
我是 flask 和部署过程的新手
我的 dash.py 设置如此
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)
和我的 nginx 文件
server {
listen 80;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location / {try_files $uri @yourapplication; }
location @yourapplication {
include uwsgi_params;
uwsgi_pass unix:/var/www/School-Dashboard/dash_clean.sock;
}
}
…但我不确定我必须在我的 wsgi ini 文件中将模块参数设置为什么。
[uwsgi]
#application's base folder
base = /var/www/School-Dahboard
#python module to import
module = dash_clean:app #?????? WHAT DO I DO HERE
#home = %(base)/venv
pythonpath = %(base)
#socket file's location
socket = /var/www/School-Dashboard/dash_clean.sock
#permissions for the socket file
chmod-socket = 660
#location of log files
logto = /var/log/uwsgi/%n.log
由于我的 uwsgi 文件,我不断收到错误的网关错误。
这是来自 uwsgi 的日志。
Starting uWSGI 2.0.17.1 (64bit) on [Mon Nov 5 12:47:42 2018] ***
compiled with version: 5.4.0 20160609 on 03 November 2018 06:53:29
os: Linux-4.15.0-36-generic #39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018
nodename: xxxxxxxx
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /var/www/School-Dashboard
detected binary path: /home/concent/.local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 31145
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/School-Dashboard/dash_clean.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x22b9330
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/School-Dahboard to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x22b9330 pid: 20070 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 20070, cores: 1)
所以我已经这样设置了 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;
}
}
我的 uwsgi 文件为....
[uwsgi]
module = dash_clean:server
master = true
processes = 5
socket = dashboard.sock
chmod-socket = 660
vacuum = true
die-on-term = true
我只需要更改模块参数
模块参数应该是
module = dash:server
这是因为模块实际上是实例化 flask 应用程序实例的 python 文件的名称。在这种情况下,它在您的 dash.py 中。虽然,在您随后的评论中,您似乎引用了 dash_clean.py,但在这种情况下,它应该是:
module = dash_clean:server
模块名称后面的部分是"callable"的名称,或者是flask应用程序的变量名称。
您在代码示例中将其定义为:
server = flask.Flask(__name__)
或者,您可以在 ini
中单独定义它们
module = dash
callable = server
我是 flask 和部署过程的新手 我的 dash.py 设置如此
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)
和我的 nginx 文件
server {
listen 80;
server_name localhost;
charset utf-8;
client_max_body_size 75M;
location / {try_files $uri @yourapplication; }
location @yourapplication {
include uwsgi_params;
uwsgi_pass unix:/var/www/School-Dashboard/dash_clean.sock;
}
}
…但我不确定我必须在我的 wsgi ini 文件中将模块参数设置为什么。
[uwsgi]
#application's base folder
base = /var/www/School-Dahboard
#python module to import
module = dash_clean:app #?????? WHAT DO I DO HERE
#home = %(base)/venv
pythonpath = %(base)
#socket file's location
socket = /var/www/School-Dashboard/dash_clean.sock
#permissions for the socket file
chmod-socket = 660
#location of log files
logto = /var/log/uwsgi/%n.log
由于我的 uwsgi 文件,我不断收到错误的网关错误。
这是来自 uwsgi 的日志。
Starting uWSGI 2.0.17.1 (64bit) on [Mon Nov 5 12:47:42 2018] ***
compiled with version: 5.4.0 20160609 on 03 November 2018 06:53:29
os: Linux-4.15.0-36-generic #39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018
nodename: xxxxxxxx
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /var/www/School-Dashboard
detected binary path: /home/concent/.local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 31145
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/School-Dashboard/dash_clean.sock fd 3
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x22b9330
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/School-Dahboard to pythonpath.
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x22b9330 pid: 20070 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 20070, cores: 1)
所以我已经这样设置了 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;
}
}
我的 uwsgi 文件为....
[uwsgi]
module = dash_clean:server
master = true
processes = 5
socket = dashboard.sock
chmod-socket = 660
vacuum = true
die-on-term = true
我只需要更改模块参数
模块参数应该是
module = dash:server
这是因为模块实际上是实例化 flask 应用程序实例的 python 文件的名称。在这种情况下,它在您的 dash.py 中。虽然,在您随后的评论中,您似乎引用了 dash_clean.py,但在这种情况下,它应该是:
module = dash_clean:server
模块名称后面的部分是"callable"的名称,或者是flask应用程序的变量名称。
您在代码示例中将其定义为:
server = flask.Flask(__name__)
或者,您可以在 ini
中单独定义它们module = dash
callable = server