【发布时间】:2018-09-16 19:06:48
【问题描述】:
我正在使用 python3.7 标准环境创建 AppEngine 应用程序。该应用程序在本地运行正常,但在上传时会在浏览器中引发 500 错误,它显示:
"Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
没有为 python3.7 启用调试(它告诉我在查看调试器时)。并且日志条目中没有针对 500 响应的错误消息提示。
如何继续调试并了解应用程序发生了什么?
我应该注意,我正在尝试使用 Selenium 网络驱动程序来运行无头 chrome,但我不能 100% 确定这是否与此环境兼容,我只是想试一试。
按照建议添加日志
https://console.cloud.google.com/logs/viewer?project={project-id}&resource=gae_app%2Fmodule_id%2Fdefault%2Fversion_id%2F20180916t193009&minLogLevel=0&expandAll=false×tamp=2018-09-17T18%3A18%3A21.295000000Z&customFacets&limitCustomFacetWidth=true&interval=PT1H&scrollTimestamp=2018-09-17T18%3A16%3A59.235127000Z&advancedFilter=resource.type%3D%22gae_app%22%0Aresource.labels.zone%3D%22us-west2-3%22%0Aresource.labels.project_id%3D%22{project-id}%22%0Aresource.labels.version_id%3D%2220180916t193009%22%0Aresource.labels.module_id%3D%22default%22%0Atimestamp%3D%222018-09-17T18%3A16%3A57.883459000Z%22%0AinsertId%3D%225b9fef9e0005ebc57890705d%22&dateRangeUnbound=both
{
httpRequest: {
status: 500
}
insertId: "5b9fef9e0005ebc57890705d"
labels: {
clone_id: "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"
}
logName: "projects/{project-id}/logs/appengine.googleapis.com%2Frequest_log"
operation: {
first: true
id: "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"
last: true
producer: "appengine.googleapis.com/request_id"
}
protoPayload: {
@type: "type.googleapis.com/google.appengine.logging.v1.RequestLog"
appEngineRelease: "1.9.64"
appId: "m~{project-id}"
cost: 4.7272999999999996e-8
endTime: "2018-09-17T18:17:02.387819Z"
finished: true
first: true
host: "{project-id}.appspot.com"
httpVersion: "HTTP/1.1"
instanceId: "00c61b117c38b726d0ba73ce89f222fe10b9b189fae907de84b949ab7a3b88ec4bdc4484"
instanceIndex: -1
ip: "80.195.185.178"
latency: "4.504360s"
line: [
0: {
logMessage: "This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application."
severity: "INFO"
time: "2018-09-17T18:17:02.387649Z"
}
]
megaCycles: "6127"
method: "GET"
requestId: "5b9fef9900ff0d7b03fbff00a7c100016d7e7370656e642d6d6f6e69746f720001323031383039313674313933303039000100"
resource: "/"
responseSize: "423"
startTime: "2018-09-17T18:16:57.883459Z"
status: 500
traceId: "37cee4aaaa0b14fbaa6d57b7842527dc"
traceSampled: true
urlMapEntry: "auto"
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
versionId: "20180916t193009"
wasLoadingRequest: true
}
receiveTimestamp: "2018-09-17T18:17:02.563417716Z"
resource: {
labels: {
module_id: "default"
project_id: "{project-id}"
version_id: "20180916t193009"
zone: "us-west2-3"
}
type: "gae_app"
}
severity: "INFO"
timestamp: "2018-09-17T18:16:57.883459Z"
trace: "projects/{project-id}/traces/37cee4aaaa0b14fbaa6d57b7842527dc"
traceSampled: true
}
【问题讨论】:
-
您可以查看您的logs 并检查此请求发生的同一时间范围。如果您可以在此处发布相关的日志实体,您将获得更好的解决方案。
-
@Yurci 感谢您的建议。我听从了你的建议。
-
正如你所提到的,你的日志并没有暗示很多关于这个问题。此时,我建议实现您的自定义logging,它也将输出到Stadriver Logging。最好的办法是检测导致此错误的代码部分。
-
感谢@Yurci - 这启发了我插入一个简单的 try/catch 块来解决问题。对我来说可悲的是,在这种环境下似乎还不能使用 headless chrome。
-
@Yurci 再次感谢!
标签: google-app-engine google-app-engine-python