【问题标题】:NGINX Unit + Flask = not found among the available application modulesNGINX Unit + Flask = 在可用的应用程序模块中找不到
【发布时间】:2020-04-29 22:01:56
【问题描述】:

当我上传 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 the available application modules."
}

我试过了:PythonPython 3.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 单元制作简单的烧瓶演示时发生的

【问题讨论】:

    标签: python flask nginx-unit


    【解决方案1】:

    首先,您应该检查 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)。

    【讨论】:

    • 谢谢,我有一个错误:[notice] 107011#107011 no modules matching: "/usr/lib/unit/modules/*.unit.so" found
    • 那里有模块吗?你是如何安装 python 模块的?
    • 好的,Unit 是在 python 模块之前安装的。这就是为什么,
    • 是的模块在那里,我只是按照unit.nginx.org/howto/flask 上的说明进行操作,但看起来好像犯了一个错误
    • 模块类型字符串必须在日志中完全匹配。喜欢python 3.6.9 (见上面的日志)而不是python 3.6
    猜你喜欢
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    相关资源
    最近更新 更多