Google App Engine 标准环境中的“纱线:未找到”

问题描述

我正在将现有的 GAE Flex 应用程序迁移到 GAE 标准版,但该应用程序无法启动。 gcloud app deploy 命令成功,但网络服务器进程在调用 yarn 时失败:

[start] 2021/04/23 16:40:57.592718 No entrypoint specified,using default entrypoint: /serve
[start] 2021/04/23 16:40:57.596207 Starting app
[start] 2021/04/23 16:40:57.596522 Executing: /bin/sh -c exec /serve
[start] 2021/04/23 16:40:57.602799 Waiting for network connection open. Subject:"app/invalid" Address:127.0.0.1:8080
[start] 2021/04/23 16:40:57.603189 Waiting for network connection open. Subject:"app/valid" Address:127.0.0.1:8081
[serve] 2021/04/23 16:40:57.616964 Serve started.
[serve] 2021/04/23 16:40:57.617857 Args: {runtimeLanguage:nodejs runtimeName:nodejs14 memoryMB:256 positional:[]}
[serve] 2021/04/23 16:40:57.620632 Running /bin/sh -c DEBUG=express:*,typeorm:* yarn ts-node:run src/index.ts
sh: 1: yarn: not found
[start] 2021/04/23 16:40:57.628730 Start program Failed: Failed to detect app after start: ForAppStart(): [aborted,context canceled. subject:"app/valid" Timeout:30m0s,attempts:4 aborted,context canceled. subject:"app/invalid" Timeout:30m0s,attempts:5]
Container called exit(1). 

似乎 yarn 被拾取并且在构建步骤中工作得很好,但在运行时却没有。 Cloudbuild 日志包含一堆与此类似的行:

Step #7 - "exporter": Reusing layer 'google.nodejs.yarn:env' 

app.yaml 是最小的:

runtime: nodejs14
service: /* redacted */

resources:
  cpu: 2
  memory_gb: 2

includes:
  - env_variables.production.yaml

#[START cloudsql_settings]
beta_settings:
  cloud_sql_instances: /* redacted */
#[END cloudsql_settings]

package.json 大致如下所示:

{
  "engines": {
    "node": ">=14"
  },...,"scripts": {
    "start": "DEBUG=express:*,typeorm:* yarn ts-node:run src/index.ts","ts-node:run": "ts-node -r tsconfig-paths/register -r dotenv/config"
  }
}

我可能的解决方法是什么?我想避免切换到 npm,因为一堆包脚本已经依赖于 yarn,并且需要时间来确保更改不会影响它们。

在 GCP github 上搜索解决方案,我在 ruby​​-docker 镜像中发现了一个 similar issue。这很可能是 GCP 方面的一个临时错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)