Google Cloud Functions Cron作业无法正常工作 [英] Google Cloud Functions Cron Job Not Working

查看:128
本文介绍了Google Cloud Functions Cron作业无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Firebase Cloud Functions中设置预定功能 .作为一个简单的测试,我试图重新创建文档页面上显示的示例:

I am trying to set up a scheduled function in Firebase Cloud Functions. As a simple test, I have tried to recreate the sample shown on the documentation page:

const functions = require('firebase-functions')

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

但是,当我运行firebase serve --only functions时,出现以下错误:

However, when I run firebase serve --only functions, I get the following error:

function ignored because the pubsub emulator does not exist or is not running.

有什么主意为什么收到此消息以及如何解决它?

Any idea why I get this message and how I can fix it?

推荐答案

摘录自 Firebase的本地模拟器:

Firebase CLI包括一个Cloud Functions仿真器,它可以仿真以下功能类型:

The Firebase CLI includes a Cloud Functions emulator which can emulate the following function types:

  • HTTPS函数
  • 可调用函数
  • Cloud Firestore功能
  • HTTPS functions
  • Callable functions
  • Cloud Firestore functions

因此,本地Firebase模拟器当前不支持pubsub,并且错误消息似乎可以确认这一点.因此,目前,您无法在本地运行pubsub触发的Cloud Functions.

So the local Firebase emulators don't currently support pubsub, and the error message seems to confirm that. So for the moment, you can't run pubsub triggered Cloud Functions locally.

提交了一项功能请求,要求向模拟器添加PubSub支持.您可能想在那里阅读(并可能发表评论),因为所采取的方向可能与您的需求不符.

A feature request for adding PubSub support to the emulator was filed. You might want to read up (and possibly comment) there, as the direction taken may or may not match with your needs.

本地shell 确实支持调用pubsub函数.当然,这是完全不同的,但暂时可以作为解决方法.

The local shell does support invoking pubsub functions. That is of course quite different, but might be useful as a workaround for the moment.

这篇关于Google Cloud Functions Cron作业无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆