Is it a good idea to enable --inspect for nodejs in production (kubernetes)? Is it a good idea to enable --inspect for nodejs in production (kubernetes)? kubernetes kubernetes

Is it a good idea to enable --inspect for nodejs in production (kubernetes)?


will it impact performance or memory usage?

Both probably negligiable if just having the flag enabled, mileage may vary if actually live debugging.

Is it good practice

I would say no, and it does have security implications. Although, this would only be a problem if you were to set a public IP, by default debugging would only be permitted on the localhost.

My.advice would be create a separate Dockerfile for prod.


While not doing any of the above, you can always enable the debugger by sending a signal to the process without restarting the application:

kill -usr1 ${PID}


Figured a better solution.Create a wrapper script which enables debugging only for non-production environments. For production if it is absolutely necessary, it is better to manually exec into pod and debug.Here is the script: start.sh

#!/bin/shif [ "$ENVIRONMENT" = "production" ] ;then npm start;else npm run debug;fi

and in the dockerfile,

CMD [ "/app/src/start.sh" ]