【Firebase Functions】Functionsの定期実行の方法
定期的にFirebase Functionsを実行させたいという場合には、Cloud Schedulerを使用できます。
以下のようなファンクションを設定することによって、5分毎に処理が実行されます。
exports.removeMember = functions.pubsub.schedule('every 5 minutes').onRun((context) => { console.log('This will be run every 5 minutes!'); return null; });
('every 5 minutes')の部分はcron.yaml構文というもので、以下のリンクが参考になります。
cron.yaml Reference | App Engine standard environment for Python 2 | Google Cloud
注意点としては、毎回実行毎に$0.10が費用として掛かってくるという点です。
それに基づき、従量課金制の「Blasze」モードでなければCloud Schedulerは使用できません。
Schedule functions | Firebase