Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bind Host to Functions Emulator inspect argument #1898

Merged

Conversation

collindever
Copy link
Contributor

@collindever collindever commented Jan 3, 2020

Description

Returns host from the functionsEmulator::getinfo() function in case no arg was passed and binds inspect to the same host the functions emulator is running on.

This is useful for running on Docker containers where services need to bind to 0.0.0.0. Issue was also raised in the now archived cloud-functions-emulator repo here googlearchive/cloud-functions-emulator#325 and a similar fix is proposed in their pull request here. googlearchive/cloud-functions-emulator#326

Scenarios Tested

With no host passed in the firebase.json debug binds to default localhost sample test output for the command firebase emulators:start --inspect-functions

i  emulators: Starting emulators: functions
⚠  functions: You are running the functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
✔  functions: Using node@8 from host.
✔  functions: Emulator started at http://localhost:5001
i  functions: Watching "/home/node/app/functions" for Cloud Functions...
>  Debugger listening on ws://localhost:9229/bed89267-5c07-47c1-87fc-41154f0e40d3

Adding the following to firebase.json

    "emulators": {
        "functions": {
          "host": "0.0.0.0"
        }
      }

and running the same command as above results in ...

i  emulators: Starting emulators: functions
⚠  functions: You are running the functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel.
✔  functions: Using node@8 from host.
✔  functions: Emulator started at http://0.0.0.0:5001
i  functions: Watching "/home/node/app/functions" for Cloud Functions...
>  Debugger listening on ws://0.0.0.0:9229/6f51ba0f-d092-4cb4-87e2-e0da4392bbf4

Confirmed I could connect to debugger with vsCode and the following launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach",
            "address": "0.0.0.0",
            "port": 9229,
            "restart": true,
            "skipFiles": [
                "<node_internals>/**"
            ]
        }
}

… binds inspect to the same host the functions emulator is running on
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@coveralls
Copy link

coveralls commented Jan 3, 2020

Coverage Status

Coverage decreased (-0.05%) to 65.569% when pulling 24a1d09 on collindever:bind-functions-inspect-to-host into 51523c0 on firebase:master.

@samtstern
Copy link
Contributor

@collindever thanks for the contribution! Seems like a reasonable change. Could you:

a) Take a look at the CLA (you only need to do this once and it covers all Google repos)
b) Update the PR description to fill in the missing sections.

@samtstern samtstern self-requested a review January 3, 2020 21:58
@collindever collindever changed the title Add Bind Host to Functions Emulator inspect argument Jan 3, 2020
@collindever collindever marked this pull request as ready for review January 3, 2020 23:08
@collindever
Copy link
Contributor Author

@googlebot I signed it!
@samtstern thanks for taking a look, I appreciate your time! Let me know if you need anything else from me.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Manual indication that this has passed CLA. and removed cla: no labels Jan 3, 2020
@samtstern
Copy link
Contributor

@collindever this is great thank you! Will merge once the CI passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants