[英]Error executing google cloud function in google cloud, but working fine in local
[英]Google Scheduled Cloud Function not working
不太確定問題是什么或如何部署它,我的代碼如下:
exports.autoLockWeek = functions.pubsub.schedule('50 20 * * FRI')
.timeZone('America/New_York')
.onRun((context) => {
sceduleLockRef.child("AutoLockWeek").once('value').then(function(snap) {
gamesRef.orderByChild("WeekId").equalTo(parseInt(snap.val())).once('value').then(function(snapshot) {
snapshot.forEach(function(child) {
gamesRef.child(child.key).update({
isPlayed: true
});
});
});
});
return null;
});
我不確定我現在如何部署它?!
我能夠部署它,因為我可以在我的雲功能列表中看到它,但是當“命中”時 function 沒有像我預期的那樣觸發?
Cloud Functions 是短暫的,並在完成執行或設置超時后退出(第一代最多 9 分鍾,第二代最多 60 分鍾)。 所以你不能在你的 function 中設置一個時間表,因為它不會運行才能執行它。
您需要在 function之外設置時間表,這可以觸發 function 執行。 您可以使用 Cloud Scheduler 執行此操作。 這可以將 cron 計划作為作業進行管理,並通過向 URL 發出 HTTP 請求來觸發 function。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.