本文介绍了如何使用 Firebase 运行 cron 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Firebase 运行 cron 作业.基本上,我需要运行一个函数,该函数每天在太平洋标准时间凌晨 12:00 进行大量 API 调用并将数据推送到 firebase.有没有办法让我在 Firebase 的服务器端做到这一点?
I am trying to run a cron job with Firebase. Basically I need to run a function that makes a ton of API calls and pushes data to firebase at 12:00am PST every day. Is there a way for me to do this on the server side with Firebase?
我看到有这个模块这里,但我不明白它是如何工作的全部.如果有人有任何想法或知道上述模块如何工作,那就太棒了.
推荐答案
在 2019 年 I/O 大会上,它宣布了一项新功能,可以使用 Firebase 函数执行 cronjobs.
At I/O 2019 it was announced a new feature to do cronjobs with firebase functions.
export scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
console.log(‘This will be run every 5 minutes!’);
});
片段 2
exports.scheduleJobs = functions.pubsub.
schedule("every day 03:00").onRun(async() => {
// do something
console.log("All done! See you tomorrow morning!");
});
这篇关于如何使用 Firebase 运行 cron 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!