为什么我的挂载点在UWSGI配置中不起作用?

时间:2019-10-31 02:36:59

标签: python flask uwsgi

我整个晚上都在看,但失败了。

我有一个python软件包saiku,里面有一个

main.py
__init__.py 

,然后是其中的许多其他程序包和内容。

main.py:

from saiku import application
from saiku.core.datasources import ConnectionManager

print("HELLO")
if __name__ == '__main__':
    c = ConnectionManager()
    c.load()

初始化 .py:

from flask_cors import CORS
from flask import Flask
from saiku.config import config

SESSION_ID_COOKIE = 'JSESSIONID'
EMPTY_SESSION_DATA = {"isadmin": False, "language": "en"}

application = Flask(__name__)
application.debug = True
application.config['SECRET_KEY'] = config['JWT_SECRET']

CORS(application) 

import saiku.rpc.server
print("HELLLO")

if __name__ == '__main__':
    application.run(host='0.0.0.0', port=str(8081), threaded=False)

但是当我运行uWSGI脚本时,它可以在根url上运行python代码,但是我试图将其映射到/ api并失败。

这是一个例子:

uwsgi -H ../flask/ --manage-script-name --mount api=saiku/main.py --socket 127.0.0.1:8080 --protocol=http --callable application --module saiku.main:application

这实际上使它同时运行和中断。 --module saiku.main:application使Flask在/

上运行

但是我无能为力,无法使/ api使用安装程序。

*** Starting uWSGI 2.0.18 (64bit) on [Thu Oct 31 02:30:04 2019] ***
compiled with version: 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8) on 31 October 2019 00:54:41
os: Darwin-19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64
nodename: Toms-MacBook-Pro.local
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /Users/tombarber/Projects/saiku4/saiku-python/src
detected binary path: /Users/tombarber/Projects/saiku4/saiku-python/flask/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 2784
your memory page size is 4096 bytes
detected max file descriptor number: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8080 fd 3
Python version: 3.7.4 (default, Jul  9 2019, 18:13:23)  [Clang 10.0.1 (clang-1001.0.46.4)]
Set PythonHome to ../flask/
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x7fc74f901210
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72888 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
HELLLO
HELLO
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7fc74f901210 pid: 69466 (default app)
mounting saiku/main.py on api
HELLLO
HELLO
WSGI app 1 (mountpoint='api') ready in 0 seconds on interpreter 0x7fc74df91820 pid: 69466
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 69466, cores: 1)
[pid: 69466|app: 0|req: 1/1] 127.0.0.1 () {36 vars in 1386 bytes} [Thu Oct 31 02:30:09 2019] GET /api => generated 232 bytes in 13 msecs (HTTP/1.1 404) 3 headers in 104 bytes (2 switches on core 0)
[pid: 69466|app: 0|req: 2/2] 127.0.0.1 () {32 vars in 1349 bytes} [Thu Oct 31 02:30:12 2019] GET / => generated 29 bytes in 22 msecs (HTTP/1.1 200) 3 headers in 96 bytes (2 switches on core 0)

因此,您可以在此处看到它试图在api上装载东西,但是该端点返回404,而/则返回200和状态消息。

0 个答案:

没有答案