【问题标题】:App engine Java application only runs on F instance?App引擎Java应用程序只运行在F实例上?
【发布时间】:2021-09-04 03:38:11
【问题描述】:

我尝试在 B2 实例上将 spring java 11 应用程序部署到 GCP 应用程序引擎,它部署但立即崩溃并出现此单一错误:

textPayload: "[start] 2021/06/20 18:09:58.614416 Start program failed: termination triggered by nginx exit"

所以这次我在 F 实例上再次尝试,它运行良好。应用引擎 B 实例不支持 Java 吗?我正在阅读文档,它似乎应该可以工作。我再次尝试使用 B 实例仅更改我的 app.yaml 文件,但它再次崩溃并抛出相同的错误。是否有一些关于 F 和 B 实例之间差异的不成文文档?

仅供参考,以防在尝试 F 和 B 实例时这是我的 app.yaml:

B 实例:

runtime: java11
env: standard 
instance_class: B2 
service: hello-there 
basic_scaling: 
    max_instances: 2 
    idle_timeout: 10m

F 实例:

runtime: java11
env: standard 
instance_class: F4 
service: hello-there 
automatic_scaling: 
    max_instances: 1

I did more attempts and i captured the tail log here:
2021-06-20 01:52:08 ho-api[1]
2021-06-20 01:52:08 ho-api[1]    .   ____          _            __ _ _
2021-06-20 01:52:08 ho-api[1]   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2021-06-20 01:52:08 ho-api[1]  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2021-06-20 01:52:08 ho-api[1]   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2021-06-20 01:52:08 ho-api[1]    '  |____| .__|_| |_|_| |_\__, | / / / /
2021-06-20 01:52:08 ho-api[1]   =========|_|==============|___/=/_/_/_/
2021-06-20 01:52:08 ho-api[1]   :: Spring Boot ::                (v2.4.1)
2021-06-20 01:52:08 ho-api[1]
2021-06-20 01:52:08 ho-api[1]  2021-06-20 01:52:08.180  INFO 11 -.

。 . . . . .

 : Started Hello in 10.229 seconds (JVM running for 11.56)
Default
2021-06-20 15:09:58.513 ADT
I0620 18:09:46.223078 20 jvmti_agent.cc:159] Java debuglet initialization started
Default
2021-06-20 15:09:58.521 ADT
I0620 18:09:46.224159 20 jvmti_agent.cc:193] Java debuglet initialization completed
Default
2021-06-20 15:09:58.521 ADT
I0620 18:09:46.370362 20 jvmti_agent.cc:204] Java VM started
Default
2021-06-20 15:09:58.521 ADT
I0620 18:09:46.395424 20 jvmti_agent.cc:214] JvmtiAgent::JvmtiOnVMInit initialization time: 25084 microseconds
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.396665 29 jvmti_agent_thread.cc:95] Agent thread started: CloudDebugger_main_worker_thread
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.400967 29 jvm_internals.cc:370] Loading internals from /opt/cdbg/cdbg_java_agent_internals.jar
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.558127 29 jvmti_agent.cc:365] Initializing Cloud Debugger Java agent version: 2.27
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.559283 29 jni_logger.cc:31] Initializing ClassPathLookup, default classpath: true, extra classpath: []
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.576998 29 jni_logger.cc:31] Total size of indexed resources database: 3679 bytes
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.582134 29 jvm_internals.cc:131] ClassPathLookup constructor time: 23965 microseconds
Default
2021-06-20 15:09:58.522 ADT
I0620 18:09:46.582628 29 yaml_data_visibility_config_reader.cc:67] debugger-blocklist.yaml was not found. Using default settings.
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.015766 29 jni_logger.cc:31] Debuggee gcp:378392885568:15c098d156eb62e2, agentId 60ce1323-0000-2bc4-944e-582429bcf920, registered: {"debuggee":{"id":"gcp:378392885568:15c098d156eb62e2","project":"378392885568","uniquifier":"DA39A3EE5E6B4B0D3255BFEF95601890AFD80709","description":"owl-system-ho-api-1-435996213358003587","agentVersion":"google.com/java-gcp/@2","sourceContexts":[{"git":{"url":"https://github.com/owl-fullDev/HOapi.git","revisionId":"373d818bb1c2436ac0ba0689712a621f33c748e8"}}],"labels":{"version":"1","module":"ho-api","minorversion":"435996213358003587","blocklistsource":"none"}},"agentId":"60ce1323-0000-2bc4-944e-582429bcf920"}, agent version: 2.27
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.015808 29 jvmti_agent.cc:437] Attaching Java debuglet
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.018111 29 rate_limit.cc:137] CPU count: 2
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.018128 29 rate_limit.cc:145] Adjusted CPU count: 1
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.018142 29 debugger.cc:100] Initializing Java debuglet
Default
2021-06-20 15:09:58.523 ADT
I0620 18:09:48.030673 29 debugger.cc:109] Debugger::Initialize initialization time: 13 ms
Default
2021-06-20 15:09:58.524 ADT
I0620 18:09:58.406167 58 jvmti_agent.cc:222] Java VM termination
Default
2021-06-20 15:09:58.524 ADT
I0620 18:09:58.407428 29 jvmti_agent_thread.cc:99] Agent thread exited: CloudDebugger_main_worker_thread
Default
2021-06-20 15:09:58.524 ADT
I0620 18:09:58.415417 58 worker.cc:113] Debugger threads terminated
Default
2021-06-20 15:09:58.524 ADT
I0620 18:09:58.415448 58 jvmti_agent.cc:236] JvmtiAgent::JvmtiOnVMDeath cleanup time: 9298 microseconds
Default
2021-06-20 15:09:58.615 ADT
[start] 2021/06/20 18:09:58.614416 Start program failed: termination triggered by nginx exit

【问题讨论】:

  • 日志中有更多详细信息吗?
  • 由于某种原因不,GCP 似乎没有将其检测为错误。我附上了日志的截图。它似乎可以正常工作,直到它自行退出。
  • 您是否尝试使用 B 实例类监听 PORT env var 而不是 8080?
  • @guillaumeblaquiere 刚刚尝试过,删除了端口 8080 警告并更改了错误,但仍然崩溃。
  • nginx 崩溃.. 您是否尝试添加特殊的运行时文件以覆盖 nginx App Engine 配置?或者你只有java标准文件?您是否还实现了 _warmup 端点?

标签: java spring spring-boot google-app-engine google-cloud-platform


【解决方案1】:

在重新阅读应用引擎文档后,我在生命周期的深处发现了以下行。

启动 每个服务实例都是为了响应启动而创建的 请求,这是对 /_ah/start 的空 HTTP GET 请求。

应用程序需要响应一个 HTTP 代码 200,只有这样应用程序引擎才会允许应用程序继续运行,如果返回 200 以外的任何内容,它将终止应用程序。我的应用程序需要一个 auth 标头,因此它返回 401,这导致应用程序引擎终止了该实例。这仅适用于 B 实例,不适用于 F 实例。因此解决方案是将默认端点从身份验证中列入白名单。

【讨论】:

  • 哇,这成功了,我不敢相信这是多么愚蠢:D web.ignoring().antMatchers("/_ah/start"); 在 SecurityConfig 中
猜你喜欢
  • 1970-01-01
  • 2011-05-10
  • 2012-05-17
  • 2017-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-11
相关资源
最近更新 更多