python - 如何为烧瓶 azure Web 应用程序设置启动命令
问题描述
我创建了一个简单的烧瓶 Web 应用程序,并设法使用 CI/CD 从 azure devops 将其发布到 azure Web 应用程序。除了启动我的应用程序外,管道都在工作。
如果我查看 webapp 中的日志文件,就会出现 -
日志文件 default_docker.log:
2020-01-08T13:04:17.017575225Z Documentation: http://aka.ms/webapp-linux
2020-01-08T13:04:17.017579025Z Python 3.7.5
2020-01-08T13:04:17.017582725Z Note: Any data outside '/home' is not persisted
2020-01-08T13:04:17.093756525Z Starting OpenBSD Secure Shell server: sshd.
2020-01-08T13:04:17.109540649Z Site's appCommandLine: gunicorn --bind = 0.0.0.0 --timeout 600 app: application
2020-01-08T13:04:17.110379356Z Launching oryx with: -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -bindPort 8000 -userStartupCommand 'gunicorn --bind = 0.0.0.0 --timeout 600 app: application'
2020-01-08T13:04:17.114336587Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-01-08T13:04:17.116548105Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2020-01-08T13:04:17.118951024Z Build Operation ID: |DGaRVt5jG5c=.2a144509_
2020-01-08T13:04:17.554659456Z Writing output script to '/opt/startup/startup.sh'
2020-01-08T13:04:17.784203265Z Found virtual environment .tar.gz archive.
2020-01-08T13:04:17.784884970Z Removing existing virtual environment directory /antenv...
2020-01-08T13:04:17.788272497Z Extracting to directory /antenv...
2020-01-08T13:04:32.810295030Z Using packages from virtual environment antenv located at /antenv.
2020-01-08T13:04:32.817794689Z Updated PYTHONPATH to ':/antenv/lib/python3.7/site-packages'
2020-01-08T13:04:36.780635398Z usage: gunicorn [OPTIONS] [APP_MODULE]
2020-01-08T13:04:36.780670499Z gunicorn: error: unrecognized arguments: app: application
我的简化应用程序树视图看起来像这样 -
test_app/
venv/
application/
templates/
__init__.py
routes.py
errors.py
models.py
forms.py
app.py
我在 azure 门户“常规设置”中尝试了不同的启动命令,但没有解决方案
gunicorn --bind=0.0.0.0 --timeout 600 app:application
编辑:添加 app.py 和init .py
应用程序.py:
from application import app, db
from application.models import User, Post
@app.shell_context_processor
def make_shell_context():
return {'db': db, 'User': User, 'Post': Post, 'Classrooms' : Classrooms, 'ClassSession' : ClassSession, 'Teacher' : Teacher}
初始化.py
from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from logging.handlers import RotatingFileHandler
import os
from flask_bootstrap import Bootstrap
import logging
app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
login = LoginManager(app)
login.login_view = 'login'
bootstrap = Bootstrap(app)
from application import routes, models, errors
if __name__ == '__main__':
# * --- DEBUG MODE: --- *
app.run(host='127.0.0.1', port=5000, debug=True)
谁能指出我可以解决这个愚蠢问题的方向。多谢!!
解决方案
gunicorn 命令实际上并不指向 WSGIapp
对象。试试这个:
gunicorn --bind=0.0.0.0 --timeout 600 application:app
推荐阅读
- python - ModuleNotFoundError:运行 lektor 服务器时没有名为“markdown”的模块
- ios - 企业分发后运行 MDX 工具包包装 Swift 4.2 iOS 应用程序的问题。异常类型:EXC_BREAKPOINT (SIGTRAP) iOS 12.4
- node.js - 在 Node.js 中返回一个 Promise
- python - 反向传播中的错误计算无法正常工作
- docker - Docker-compose 与 Gitlab CI
- javascript - 在每次测试中重置 id 生成器的 Jest 模拟
- c# - 为数据库中的查找表自动读取 MemoryCache 或 InMemory
- google-sheets - Hihglight 从 Google 表格中的两个不同工作表中复制单元格
- pdf - 自动从 SolidWorks PDM 获取 PDF 文件并合并到一个产品组合中
- javascript - bcrypt.compare() 是异步的,这是否一定意味着肯定会发生延迟?