sysgears / spinjs

SpinJS is now Zen! The project has been renamed and moved to Larix Framework.
https://github.com/sysgears/larix/tree/master/packages/zen
MIT License
43 stars 8 forks source link

Adding a flag (or way) to configure node-debugger's host location #17

Closed IsaaX closed 5 years ago

IsaaX commented 5 years ago

Lovely package! So I've been using spinjs and have recently dockerized the application in order to obtain https and in that it's almost functional. So one of the things that I haven't been able to configure correctly is the ability to debug when running on a docker container. That mainly being the builder ends up binding inspection host to localhost meaning it's not accessible from the outside world and only in the container. Here is some context.

If there was a way to bind to 0.0.0.0 in the container then it would bind it to the 9229 port on my machine and I would be able to inspect on it.

Spawning node --inspect=9229 /repository/myrepo/packages/server/build/index.js
Debugger listening on ws://127.0.0.1:9229/e74eba67-dadb-41ca-8255-75aa47bf12dd
For help, see: https://nodejs.org/en/docs/inspecto

https://nodejs.org/en/docs/guides/debugging-getting-started/

--inspect=[host:port] | Enable inspector agentBind to address or hostname host (default: 127.0.0.1)Listen on port port (default: 9229)

I hope this makes sense and would love your input on this. If we can decide on an approach, I wouldn't mind tackling it and submitting a PR. Any thoughts?

Once again, appreciate this repo! It's been great.

larixer commented 5 years ago

@IsaaX Yes. Well, the way I would like this to work is to have minimum configuration. We are detecting docker already via is-docker package, for example here: https://github.com/sysgears/spinjs/blob/ba8a348d7967c7c40c58893de9fb8a8ddbad7194/src/executor.ts#L271 So, maybe when we submit arguments for --inspect and we run inside docker (is-docker says us so), we can use by default 0.0.0.0:port, instead of just port

What do you think?

IsaaX commented 5 years ago

That's an excellent solution! Sounds easy to implement as well. I can give it a go and submit a PR. If it seems too challenging I"ll let you know.

larixer commented 5 years ago

@IsaaX Thank you, sounds good!

larixer commented 5 years ago

Closed via #18

larixer commented 5 years ago

Published in spinjs@0.4.168