skip to Main Content

I have an express app running on firebase, I want it to have the minInstances:1 config

Currently I Use:

import {onRequest} from "firebase-functions/v2/http
export const xx = onRequest(app);

Only examples I can find are for individual functions:

functions.runWith({ minInstances: minInstancesConfig}).https....

how can I wrap the onRequest(app) with the minInstances config?

*Also I saw a suggestion about using the Cloud Scheduler for short intervals, I tried it and it just drives the server crazy:
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    This seems to do the job:

    export const xx = onRequest({
        minInstances: 1,
    }, app);
    

  2. It’s the same as the example using req and res in the documentaion. Just give your app instead of the function callback.

    functions
        .runWith({ minInstances: minInstancesConfig})
        .https
        .onRequest(app)
    

    The addition of runWith in the chain of calls here doesn’t change the way onRequest receives parameters. It just changes the way to resulting container behaves under load.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search