Google App Engine 灵活环境 0 个实例

2024-03-09

在过去的一周里,我发现我的 GAE 灵活环境中的实例数量降至 0,并且没有新实例启动。我对灵活环境的理解是,这不应该是可能的......(https://cloud.google.com/appengine/docs/the-appengine-environments https://cloud.google.com/appengine/docs/the-appengine-environments)

我想知道是否有其他人看到过这些问题,或者他们之前是否已经解决过这个问题。我的一个假设是,这可能是我的健康监控端点的问题,但当我检查代码时,没有发现任何问题。

直到上周,这对我来说才成为问题,现在看来我必须每隔几天重新部署我的环境(没有任何更改),只是为了“重置”实例。值得注意的是,我在同一个 App Engine 项目下有两个服务,都运行灵活的版本。但我似乎只对其中一项服务(我称之为工作人员服务)有这个问题。

App Engine UI 的屏幕截图:

日志 UI 的屏幕截图显示了正在发送的 SIGTERM:

PS - 这是否与最近出现的 Google 计算问题有关......https://news.ycombinator.com/item?id=18436187 https://news.ycombinator.com/item?id=18436187

编辑:添加“worker”服务的 yaml 文件。请注意,我使用 Honcho 添加端点以通过 Flask 监控工作线程服务的运行状况。我也添加了这些代码示例。

yaml 文件

service: worker
runtime: python
threadsafe: yes
env: flex
entrypoint: honcho start -f /app/procfile worker monitor

runtime_config:
  python_version: 3

resources:
  cpu: 1
  memory_gb: 4
  disk_size_gb: 10

automatic_scaling:
  min_num_instances: 1
  max_num_instances: 20
  cool_down_period_sec: 120
  cpu_utilization:
    target_utilization: 0.7

Honcho 的 Procfile

default: gunicorn -b :$PORT main:app
worker: python tasks.py
monitor: python monitor.py /tmp/psq.pid

监视器.py

import os
import sys

from flask import Flask


# The app checks this file for the PID of the process to monitor.
PID_FILE = None


# Create app to handle health checks and monitor the queue worker. This will
# run alongside the worker, see procfile.
monitor_app = Flask(__name__)


@monitor_app.route('/_ah/health')
def health():
    """
    The health check reads the PID file created by tasks.py main and checks the proc
    filesystem to see if the worker is running.
    """
    if not os.path.exists(PID_FILE):
        return 'Worker pid not found', 503

    with open(PID_FILE, 'r') as pidfile:
        pid = pidfile.read()

    if not os.path.exists('/proc/{}'.format(pid)):
        return 'Worker not running', 503

    return 'healthy', 200


@monitor_app.route('/')
def index():
    return health()


if __name__ == '__main__':
    PID_FILE = sys.argv[1]
    monitor_app.run('0.0.0.0', 8080)

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Google App Engine 灵活环境 0 个实例 的相关文章

随机推荐

  • 优雅地实现 ExecutorServices 的队列长度指示器

    为什么 哦 为什么不java util concurrent为其提供队列长度指标ExecutorService是 最近我发现自己在做这样的事情 ExecutorService queue Executors newSingleThreadE
  • kable col.names 和 header 中的文本下标

    我似乎无法使用 kableExtra 包和包含下标的列名或标题生成 html 表 我尝试了多种方法 但它只是不断显示没有下标的输出 以mtcars数据集为例 data mtcars library kableExtra mtcars gt
  • 如何克服 Godot 将按钮字体更改为默认颜色的问题?

    我正在使用 Godot 4 我在容器中手动创建了很多按钮 我在主场景中设置了一个颜色变量 tempcol 当我单击带有 tempcol 设置的按钮时 比如 Color Red 按钮的字体颜色更改为白色 似乎是默认字体颜色 但是当我单击另一个
  • 银光 mpeg-4

    我目前正在开发一个项目 我需要创建一个网络视频播放器 在当前状态下 我的应用程序播放客户端提供的动态 JPEG 和 H264 AVC 格式的录音 问题是 他还想要 MPEG 4 第 2 部分 视觉 我称之为 mp4v 根据this http
  • iOS 中的精确计时

    我正在查看 iOS SDK 中的 Metronome 示例代码 http developer apple com library ios samplecode Metronome Introduction Intro html http d
  • Zend:如何在我的所有视图中添加网页标题?

    现在我必须在所有视图中分别添加标题 如下所示 and 现在如果我想改变测试项目标题的一部分 那么我必须在我的所有观点中更改它 我怎么能在BootStrap php并将其添加到所有视图中 每当我必须改变这一点时 我都会在一个地方改变它 你应该
  • 如何使用 LD_PRELOAD 运行 gdb?

    我有一个使用 LD PRELOAD 的程序 该程序应该像这样运行 这个 LD PRELOAD path to libfoo so qemu U LD PRELOAD a out 如果 没有 gdb 这是我在运行 gdb 时所做的事情 gdb
  • PHPMailer 显示为 root 用户

    我正在使用 PHP Mailer 发送电子邮件 并且我正在使用 SMTP 这是我正在使用的代码 email new PHPMailer email gt IsSMTP telling the class to use SMTP email
  • 是否有使用 javascript 生成 html 的最佳实践

    我正在调用一个 Web 服务 该服务返回 JSON 格式的对象数组 我想获取这些对象并用 HTML 填充 div 假设每个对象都包含一个 url 和一个名称 如果我想为每个对象生成以下 HTML div img src the name d
  • 如何通过在 Android-Studio 中编辑 build.gradle 将我的库放在 android.jar 前面

    First Here s my Java Build Path in Eclipse common jar core jar framework jar layout jar这四个jar是从Android源代码中打包出来的 其中包含一些开发
  • 覆盖 required_without_all laravel 的单个消息

    我一直在 laravel 中至少使用一个 required without all 字段 这是我的规则代码 rental company id gt required without all camper id take over stat
  • PostgreSQL 返回查询日期的精确或最接近日期

    我有以下 postgresql 语法 它返回值 WHERE session date 匹配 date string 问题是有时 date string 在表中不可用 所以我希望返回最接近 date string 的日期 date strin
  • 模拟器中的iPhone相机

    有没有办法在模拟器中使用 iPhone 摄像头测试代码 一定有人写过一些东西 你可以有一个模拟相机的替换组件 在模拟器中 您可以访问一些示例照片库图像 使用 UIImagePickerControllerSourceTypePhotoLib
  • MySQL 何时尝试更新列的索引?

    我正在尝试确定 MySQL 在什么情况下更新索引 假设我有下表 CREATE TABLE MyTable ID INT NOT NULL AUTO INCREMENT MyIndexedColumn VARCHAR NOT NULL MyN
  • 比较 Access SQL 查询中的日期

    我在使用 Access sql 查询时遇到问题 我对此很陌生 所以作为一个菜鸟 很难弄清楚语法 以下是我的查询 SELECT FROM BookingMaster WHERE JourneyDate 01 08 2012 下面是各自的表格数
  • 如何使用 Conduit 保存文件?

    如何使用管道的库保存文件 我浏览了管道的教程 但似乎找不到任何东西 这是我的用例 main IO main do xxs lt lines lt gt readFile filePath sourceList xxs pipe saveFi
  • 如何从 SwiftUI 部分中删除背景颜色? [复制]

    这个问题在这里已经有答案了 我有一个 SwiftUI 部分 如下所示 struct FormView View var body some View Form Section Button action HStack Spacer Text
  • HTTP 错误 504:尝试阅读 Reddit 评论帖子时网关超时

    我在尝试从 reddit 获取评论的 http 时遇到错误 各种 URL 都发生过这种情况 并非所有 URL 都带有特殊字符 这就是其中之一 在一小时内 可能有 1000 个或更多对 reddit com 域的请求 hdr User Age
  • 使用并行线程提高 Python 执行速度

    假设我有这个示例代码 x foo1 something1 y foo2 something2 z max x y 我想通过使用线程来提高这段代码的执行时间 希望它有帮助 不是吗 我想让事情尽可能简单 所以基本上我想做的是创建两个同时工作的线
  • Google App Engine 灵活环境 0 个实例

    在过去的一周里 我发现我的 GAE 灵活环境中的实例数量降至 0 并且没有新实例启动 我对灵活环境的理解是 这不应该是可能的 https cloud google com appengine docs the appengine envir