Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 如何为具有相同处理程序的多个cron作业设置cron.yaml?_Google App Engine - Fatal编程技术网

Google app engine 如何为具有相同处理程序的多个cron作业设置cron.yaml?

Google app engine 如何为具有相同处理程序的多个cron作业设置cron.yaml?,google-app-engine,Google App Engine,这是我的cron.yaml: cron: - description: 'cron trigger create email' url: /cron/events/createEmail schedule: every 1 hours target: cron-jobs-background-cloud-function - description: 'cron trigger create user' url: /cron/events/createUs

这是我的
cron.yaml

cron:
  - description: 'cron trigger create email'
    url: /cron/events/createEmail
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
  - description: 'cron trigger create user'
    url: /cron/events/createUser
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
cron:
  - description: 'cron-jobs-background-cloud-function'
    url: /cron/events/*
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
server.js

function taskHandler() {}

app.get('/cron/events/createEmail', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});

app.get('/cron/events/createUser', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});
app.get('/cron/events/*', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});
cron.yaml
server.js
都是重复的

cron服务是否支持如下路径模式:

cron:
  - description: 'cron trigger create email'
    url: /cron/events/createEmail
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
  - description: 'cron trigger create user'
    url: /cron/events/createUser
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
handlers:
- url: /cron/events/*
  script: [PATH TO APP]
cron.yaml

cron:
  - description: 'cron trigger create email'
    url: /cron/events/createEmail
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
  - description: 'cron trigger create user'
    url: /cron/events/createUser
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
cron:
  - description: 'cron-jobs-background-cloud-function'
    url: /cron/events/*
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
server.js

function taskHandler() {}

app.get('/cron/events/createEmail', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});

app.get('/cron/events/createUser', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});
app.get('/cron/events/*', (req, res) => {
  const topicName = req.path.split('/').slice(-1)[0];
  console.log('topicName: ', topicName);
  taskHandler(topicName);
  res.sendStatus(200);
});

我怀疑您不能在
cron.yaml
中使用通配符,但您可以在
app.yaml
中使用通配符,这应该可以实现您想要做的

保持您的
cron.yaml
如下:

cron:
  - description: 'cron trigger create email'
    url: /cron/events/createEmail
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
  - description: 'cron trigger create user'
    url: /cron/events/createUser
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
handlers:
- url: /cron/events/*
  script: [PATH TO APP]
按如下方式设置你的
app.yaml

cron:
  - description: 'cron trigger create email'
    url: /cron/events/createEmail
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
  - description: 'cron trigger create user'
    url: /cron/events/createUser
    schedule: every 1 hours
    target: cron-jobs-background-cloud-function
handlers:
- url: /cron/events/*
  script: [PATH TO APP]

然后,您可以像在您的问题中一样,对所有cron作业使用one处理程序。

在阅读了以下文档之后:,文档说
script
的值是
auto
?@novaline,我不使用Python,也不使用nodejs,所以我无法回答这个问题。您应该能够保留
app.yaml中当前的任何内容。