在Elastic Beanstalk中部署flask应用程序时出错:无法识别选项绑定

2024-10-01 00:23:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个装在弹性豆茎上的烧瓶,它的结构是: (此文件夹结构也在Flask documentation中描述)

farmerselevator/
├╴.ebextensions/
│       └─── python.config
│
├─farmerselevator/
│  │  
│  ├─── database/
│  │
│  ├─── src/
│  │      ├ api/
│  │      ├ pages/
│  │      └ helper.py
│  │
│  ├─── static/
│  │
│  ├─── templates/
│  │
│  ├─── uploads/
│  │
│  └─── __init__.py
│
│
├╴farmerselevator.egg-info/
├╴requirements.txt
└╴setup.py

Mysetup.py包含:

from setuptools import setup

setup(
    name='farmerselevator',
    packages=['farmerselevator'],
    include_package_data=True,
    install_requires=[
        'flask',
    ],
)

而mypython.config

option_settings:
  "aws:elasticbeanstalk:container:python":
    WSGIPath: setup:setup

我的/farmerselevator/__init__.py有:

from flask import Flask
application = Flask(__name__)

# internal functions for api and pages calls
import farmerselevator.src.api.buy
...

import farmerselevator.src.pages.index
...

# running the server
if __name__ == '__main__':
    application.run()

要在本地运行我的应用程序,我运行:export FLASK_APP=__init__.py,后跟export FLASK_ENV=developmentflask run

但是当我尝试在日志中部署到AWS Elastic Beanstalk时,我得到了一个错误:

----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Oct  4 18:26:30 ip-1**-**-**-** web: or: gunicorn --help [cmd1 cmd2 ...]
Oct  4 18:26:30 ip-1**-**-**-** web: or: gunicorn --help-commands
Oct  4 18:26:30 ip-1**-**-**-** web: or: gunicorn cmd --help
Oct  4 18:26:30 ip-1**-**-**-** web: error: option --bind not recognized
Oct  4 18:26:30 ip-1**-**-**-** web: [2021-10-04 18:26:30 +0000] [19198] [INFO] Booting worker with pid: 19198
Oct  4 18:26:31 ip-1**-**-**-** web: [2021-10-04 18:26:31 +0000] [19198] [INFO] Worker exiting (pid: 19198)
Oct  4 18:26:31 ip-1**-**-**-** web: usage: gunicorn [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
Oct  4 18:26:31 ip-1**-**-**-** web: or: gunicorn --help [cmd1 cmd2 ...]
Oct  4 18:26:31 ip-1**-**-**-** web: or: gunicorn --help-commands
Oct  4 18:26:31 ip-1**-**-**-** web: or: gunicorn cmd --help

----------------------------------------
/var/log/nginx/error.log
----------------------------------------
2021/10/04 17:12:47 [error] 6314#6314: *102 connect() failed (111: Connection refused) while connecting to upstream, client: 172.xx.xx.xxx, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "172.@@.@@.@@"

问题:

我的python.config错误吗?我尝试将setup.py替换为application.py,并在python.config中进行匹配,但没有成功

错误是否与目录结构有关?在我以前的版本中,我有一个application.py,而不是在Flask doc中设计的文件夹结构,它在AWS中工作


Tags: orpyimportiplogwebconfigflask