簡體   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