Python NGINX单位+;Flask=在可用的应用程序模块中找不到
上传config.json时会发生这种情况:Python NGINX单位+;Flask=在可用的应用程序模块中找不到,python,flask,nginx-unit,Python,Flask,Nginx Unit,上传config.json时会发生这种情况: sudo curl -X PUT --data-binary @config.json --unix-socket /var/run/control.unit.sock http://localhost/config { "error": "Invalid configuration.", "detail": "The module to run \"python 3.6\" is not found among th
sudo curl -X PUT --data-binary @config.json --unix-socket /var/run/control.unit.sock http://localhost/config
{
"error": "Invalid configuration.",
"detail": "The module to run \"python 3.6\" is not found among the available application modules."
}
我试过:Python
,python3.7
我尝试上载的我的config.json:
{
"listeners": {
"*:1234": {
"pass": "applications/flask"
}
},
"applications": {
"flask": {
"type": "python 3.6",
"processes": 5,
"path": "/home/123/123/",
"home": "/home/123/123/venv/",
"module": "wsgi",
"user": "root",
"group": "root"
}
}
}
当我试图用nginx单元制作简单的flask演示时,就会发生这种情况。首先,您应该检查python模块是否正确安装。为了发现它们的位置,您可以使用显示默认选项的
unitd--help
$ unitd --help
...
--modules DIRECTORY set modules directory name
default: "/usr/lib/unit/modules"
如果使用自定义systemd单元或脚本,则应选中选项--modules
只需列出模块目录中的文件:
$ ls /usr/lib/unit/modules
python3.6.unit.so python3.7.unit.so
如果有,请在unit.log的开头检查它们是否正确加载:
$ sudo more /var/log/unit.log
2020/04/29 22:24:47 [info] 13025#13025 discovery started
2020/04/29 22:24:47 [notice] 13025#13025 module: python 3.6.9 "/usr/lib/unit/modules/python3.6.unit.so"
2020/04/29 22:24:47 [notice] 13025#13025 module: python 3.7.5 "/usr/lib/unit/modules/python3.7.unit.so"
2020/04/29 22:24:47 [notice] 13024#13024 process 13025 exited with code 0
2020/04/29 22:24:47 [info] 13027#13027 router started
2020/04/29 22:24:47 [info] 13026#13026 controller started
2020/04/29 22:24:47 [info] 13027#13027 OpenSSL 1.1.1 11 Sep 2018, 1010100f
如果未加载,日志将显示原因。
单元模块版本必须与安装的单元版本匹配。如果您在运行旧版本的系统中安装了新版本,您也应该重新安装单元模块(
apt install unit dev unit-python3.6 unit-python3.7
)。谢谢,我有一个错误:[注意]107011\107011没有匹配的模块:“/usr/lib/unit/modules/*.unit.so”找到模块了吗?您是如何安装python模块的?好的,单元是在python模块之前安装的。这就是为什么,是的,模块在那里,我只是按照指令,但看起来好像犯了一个错误。模块类型字符串必须在日志中完全匹配。类似于python3.6.9
(参见上面的日志),而不是python3.6