繁体   English   中英

如何在部署 Python Bottle 服务器时通过 AWS App Runner 的健康检查测试?

[英]How to pass health check tests on AWS App Runner while deploying Python Bottle server?

我想这是一个非常愚蠢的问题,但我在 devops 方面真的很差。

我有一个小型 Python 编程项目,我需要将其部署到 Web 上。 它不是一个真正的应用程序,只是一个小脚本,我需要将其放在网上几天然后将其关闭。

我开发了一个使用 Python Bottle服务器在本地运行的脚本。 现在,我正在运行一个 AWS 实例,并尝试使用App Runner部署这个应用程序。 貌似我的环境和代码都没问题,就是健康检查过不了。 以前只在传统服务器上部署过代码,对云上的操作不是很熟悉。

11-05-2022 02:37:47 PM [AppRunner] Health check on port '8080' failed. Service is rolling back. Check your configured port number. For more information, read the application logs.
11-05-2022 02:31:36 PM [AppRunner] Performing health check on port '8080'.
11-05-2022 02:31:26 PM [AppRunner] Provisioning instances and deploying image for publicly accessible service.
11-05-2022 02:31:15 PM [AppRunner] Successfully built source code.
11-05-2022 02:26:53 PM [AppRunner] Starting source code build.
11-05-2022 02:26:52 PM [AppRunner] Successfully pulled source code.
11-05-2022 02:25:56 PM [AppRunner] Service status is set to OPERATION_IN_PROGRESS.
11-05-2022 02:25:55 PM [AppRunner] Service creation started.

这是我的“server.py”文件中的代码部分。

import os
from bottle import route, run, template, get, post, request
from scraper import scrap, get_dropdown_choices

index_html = '''My first web app! By <strong>{{ author }}</strong>.'''

@route('/')
def index():
    return template(index_html, author='Tim')

@route('/name/<name>')
def name(name):
    return template(index_html, author=name)

run(host='0.0.0.0', port=8080)

我应该怎么做才能通过健康检查测试?

没有看到你的服务器日志,我只能猜测你健康检查失败的原因。 但是让我印象深刻的一件事是from scraper import scrap ,这似乎是一个错字。

而且,确实,当我尝试运行您发布的代码时,出现此错误:

    from scraper import scrapes, get_dropdown_choices
ImportError: cannot import name 'scrap' from 'scraper' (/lib/python3.10/site-packages/scraper/__init__.py)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM