预期
定义了 Firebase Cloud Storage 目录 gs://my-project-name.appspot.com/
,当部署的 Cron 作业在 GCP 上运行时,将使用 my-project-name
的 Firestore 数据库中的所有集合填充,并按照 Schedule data exports 文档进行实现。
观察
Cron 作业已成功部署,但无法运行。日志显示 Error code 204
。
日志
2019-01-24 11:19:47.818 PST GET 500 0 B 998 ms AppEngine-Google; (+http://code.google.com/appengine) /cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups/ 0.1.0.1 - - [24/Jan/2019:11:19:47 -0800] "GET /cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups/ HTTP/1.1" 500 - - "AppEngine-Google; (+http://code.google.com/appengine)" "cloud-firestore-admin.[my-project-name].appspot.com" ms=998 cpu_ms=482 cpm_usd=0 loading_request=1 instance=00c61b117c5fba456c9edcc5f075ccacb339b96d0bc7a8e35beb60cd3fd50a149d4c2f296b app_engine_release=1.9.71 trace_id=65811179272fc9c721d10e6cab7cdf70
{
httpRequest: {
status: 500
}
insertId: "5c4a0fd4000c78b4e510bd7a"
labels: {
clone_id: "00c61b117c5fba456c9edcc5f075ccacb339b96d0bc7a8e35beb60cd3fd50a149d4c2f296b"
}
logName: "projects/[my-project-name]/logs/appengine.googleapis.com%2Frequest_log"
operation: {
first: true
id: "5c4a0fd300ff0c7e86eb62e71c0001737e636f696e76657273652d6d656469612d73746167696e670001323031393031323474313130333331000100"
last: true
producer: "appengine.googleapis.com/request_id"
}
protoPayload: {
@type: "type.googleapis.com/google.appengine.logging.v1.RequestLog"
appEngineRelease: "1.9.71"
appId: "s~[my-project-name]"
endTime: "2019-01-24T19:19:48.816961Z"
finished: true
first: true
host: "cloud-firestore-admin.[my-project-name].appspot.com"
httpVersion: "HTTP/1.1"
instanceId: "00c61b117c5fba456c9edcc5f075ccacb339b96d0bc7a8e35beb60cd3fd50a149d4c2f296b"
instanceIndex: -1
ip: "0.1.0.1"
latency: "0.998139s"
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: "2019-01-24T19:19:48.816504Z"
}
1: {
logMessage: "A problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. (Error code 204)"
severity: "ERROR"
time: "2019-01-24T19:19:48.816507Z"
}
]
megaCycles: "482"
method: "GET"
pendingTime: "0.010711670s"
requestId: "5c4a0fd300ff0c7e86eb62e71c0001737e636f696e76657273652d6d656469612d73746167696e670001323031393031323474313130333331000100"
resource: "/cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups/"
startTime: "2019-01-24T19:19:47.818822Z"
status: 500
taskName: "6c799fe7c1a404ec22117967738fcca9"
taskQueueName: "__cron"
traceId: "65811179272fc9c721d10e6cab7cdf70"
traceSampled: true
urlMapEntry: "auto"
userAgent: "AppEngine-Google; (+http://code.google.com/appengine)"
versionId: "20190124t110331"
wasLoadingRequest: true
}
receiveTimestamp: "2019-01-24T19:19:48.824360342Z"
resource: {
labels: {
module_id: "default"
project_id: "my-project-name"
version_id: "20190124t110331"
zone: "us17"
}
type: "gae_app"
}
severity: "ERROR"
timestamp: "2019-01-24T19:19:47.818822Z"
trace: "projects/[my-project-name]/traces/65811179272fc9c721d10e6cab7cdf70"
traceSampled: true
}
2019-01-24 11:19:48.816 PST
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.
2019-01-24 11:19:48.816 PST
A problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. (Error code 204)
配置
- GCP 和 Firebase 项目均已启用结算功能。
- 当前已创建一个 Firebase 存储桶,用于在名为 content 的目录下存储 mp3 和 txt 文件,并创建一个新的空目录创建名为备份来存储导出 Cron 作业的结果。
- 已按照 Configure access permissions 部分中的建议启用以下权限。
GCP 项目被定义为默认。
对于 package.json ,
name
、version
和description
属性已针对项目进行了更改。在 cron.yaml 中,
description
和url
属性是自定义的。对于url
,已尝试以下操作来导出所有集合:-
/cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups
-
尝试的解决方案
- 版本代码:在后续部署中增加版本代码。
-
cron.yaml
网址:- 在目录后添加
/
:/cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups/
- 添加
collections
查询但将其留空:/cloud-firestore-export?outputUriPrefix=gs://[my-project-name].appspot.com/backups&collections
- 在目录后添加
- IAM 权限:向我的用户帐户 my-name@domain.com 添加 Cloud Datastore Import Export Admin 权限,因为这是电子邮件与
gcloud config configurations list
下的项目关联的帐户。
最佳答案
问题是 package.json 版本不能低于 1.0.0
。我试图使用0.16.0
。我正在向文档团队发送一条注释,这应该包含在文档中以节省人们的时间。
关于javascript - Firestore 导出 Cron 作业未运行 : Error Code 204,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54355953/