在 Google 应用引擎上将 Go 程序(网络爬虫)作为 cron 作业执行

Execute a Go programm (webcrawler) as a cron job on Google appengine

如何在 Google appengine 中将单个 Go 程序 namend "gcinfo"(带有 firebase 输出的网络爬虫)作为 cron 运行?

我能够创建项目 ID 并使用 App SDK 上传 Go 程序。 cron 作业按照 cron.yaml 中的定义每 15 分钟执行一次。没有错误。但是我在日志中没有发现任何输出,并且没有写入 firebase。在 app.yaml、gcinfo.yaml 和 cron.yaml 中进行大量更改后没有结果或出现类似错误(错误代码 204)。我现在对 yaml 文件中的设置感到非常困惑。

有人可以提供或指出这些设置的简单示例吗?我想每 15 分钟在应用程序引擎中将一个 Go 程序作为 cron 运行一次。

我的项目结构是:

app.yaml

application: myproject
version: 1
runtime: go
api_version: go1

handlers:
- url: /.*
  script: _go_app

cron.yaml

cron:
- description: Ausfuehrung des tasks gcinfo
url: /gcinfo
schedule: every 15 minutes from 05:30 to 23:00
timezone: Europe/Berlin
target: gcinfo

gcinfo.yaml

application: myproject
module: gcinfo
#version: 1
runtime: go
api_version: go1

handlers:
- url: /gcinfo\.*
script: gcinfo\gcinfo.go

我的 gcinfo.go 具有以下结构

package gcinfo

import (
...
)

....

func gcinfo() {
....
}

"goapp deploy" 中的此配置没有错误,应用引擎每 15 分钟响应一次,持续 6 毫秒,但 go 程序 gcinfo 没有输出。我已经尝试将 gcinfo 设为 main,结果相同。

我找到了解决方案,现在 cron 作业运行并在作业控制中写入注释。

cron.yaml 在我的项目文件夹中

cron:
- description: Ausfuehrung des tasks gcinfo
url: /gcinfo
schedule: every 15 minutes from 05:30 to 23:00
timezone: Europe/Berlin

app.yaml 子文件夹 gcinfo

application: myproject
module: gcinfo
version: 1
runtime: go
api_version: go1

handlers:
- url: /gcinfo
  script: _go_app 

gcinfo.go(gcinfo 子文件夹)

中的关键更改
package gcinfo

import (
"net/http"
...
"appengine"
"appengine/urlfetch"
)

func init() {
 http.HandleFunc("/gcinfo", gcinfo)
}
...

func gcinfo(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
...
}

仅编写 firebase 引擎不适用于应用引擎。我将不得不做更多的研究。