Firebase Cloud Function预定功能未运行

时间:2019-10-04 16:49:41

标签: firebase google-cloud-functions

我正在尝试第一个预定的云功能。为了进行测试,我尝试每1分钟运行一次,以后会增加。

我已经部署了它,但是还没有看到它通过Firebase日志运行。

这就是我部署的内容:

const fetchMovies = require('./data/fetchMovies');
exports.fetchMovies = functions.pubsub.schedule('every 1 minute').onRun((context) => {
  console.log("Running, with this context:", context)
  fetchMovies.handler(db);
});

任何想法在这里可能不正确吗?

2 个答案:

答案 0 :(得分:0)

From the docs

5分钟示例...

exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
  console.log('This will be run every 5 minutes!');
  return null;
});

Google Cloud支持Unix Crontab和AppEngine语法 计划程序。

exports.scheduledFunctionCrontab = functions.pubsub.schedule('5 11 * * *')
  .timeZone('America/New_York') // Users can choose timezone - default is America/Los_Angeles
  .onRun((context) => {
  console.log('This will be run every day at 11:05 AM Eastern!');
  return null;
});

答案 1 :(得分:-1)

要每分钟触发一个功能,请使用字符串'* * * * *'。多数民众赞成在Unix中的每一分钟。不要忘记,每个*必须彼此隔开一个空格

赞:

const fetchMovies = require('./data/fetchMovies');

exports.fetchMovies = functions.pubsub.schedule('* * * * *').onRun((context) => {
  console.log("Running, with this context:", context)
  fetchMovies.handler(db);
});