Google Cloud Functions Cron Job Not Working

风格不统一 提交于 2019-12-24 19:49:36

问题


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
  })

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?


回答1:


From the documentation on Firebase's local emulator:

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

  • HTTPS functions
  • Callable functions
  • Cloud Firestore 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.

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.

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



来源:https://stackoverflow.com/questions/59346125/google-cloud-functions-cron-job-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!