本文介绍了Firebase Scheduler 的 Cloud Functions 时区不会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建和部署一个函数,以便在 Cloud Functions for Firebase 调度程序中定期执行,如下所示.关键是我希望它每天在日本时间 0:05 执行为 .timeZone('Asia/Tokyo').

I am currently creating and deploying a function to be executed periodically in the Cloud Functions for Firebase scheduler as shown below.The key point is that I want it to be executed every day at 0:05 Japan time as .timeZone('Asia/Tokyo').

部署本身工作正常,但是当我查看 GCP 的 Cloud Scheduler 中的内容时,时区设置为 (America/LosAngeles) 如下图所示,实际执行时间与日本时间不同.

The deploy itself is working fine, but when I look at the content in GCP's Cloud Scheduler, the Time Zone is set to (America/LosAngeles) as shown in the image below, and the actual execution time is off from Japan time.

我在 Cloud Scheduler 功能管理屏幕中手动将时区更改为日本时间,并确认达到了预期的行为,但是当我再次部署该功能时,它仍然设置为 (America/LosAngeles).

I manually changed the time zone to Japan time in the Cloud Scheduler function management screen and confirmed that the desired behavior was achieved, but when I deploy the function again, it is still set to (America/LosAngeles).

我认为它可能会受到 GCP 本身区域的影响,并且我必须更改 GCP 的区域,但我还没有找到我可以从哪里更改它.但是,我认为我应该能够从代码中为每个函数指定 .timeZone .我不知所措.

I thought it might be affected by the region of GCP itself, and that I would have to change the region of GCP, but I haven't found where I can change it from.However, I thought that I should be able to specify the .timeZone for each function from the code. I'm at a loss.

我不知道如何解决这个问题,我想知道是否有人可以帮助我.

I don't know how to solve this problem, and I'm wondering if anyone can help me.

exports.XXX = functions.pubsub
.schedule('every day 0:05')
.timeZone('Asia/Tokyo')
.onRun((context) => {
///省略
});

提前谢谢你.

推荐答案

我也遇到过同样的问题.还有一个类似的问题 在这里,降级 firebase-tools 的解决方案对我有用.

I have experienced the same problem too. There's also a similar question asked here and the solution to downgrade the firebase-tools works for me.

这篇关于Firebase Scheduler 的 Cloud Functions 时区不会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 10:58