Debug nodejs app in CF

試著忘記壹切 提交于 2019-12-08 10:47:27

问题


I follow this guide how to debug node.js application in CF and its currently not working ,

https://medium.com/@KevinHoffman/debugging-node-js-applications-in-cloud-foundry-b8fee5178a09#.ekkzo3f63

I've installed the node inspector and I see message in the logs like:

2017-03-23T15:29:21.58+0200 [APP/PROC/WEB/0]ERR Debugger listening on [::]:5858

I did the ssh command

Now what should I do ? in the guide it says the following after the ssh

  1. export PATH=$PATH:/app/.heroku/node/bin

what should be .heroku ? I'm not running in heroku ... So how which path I should provide ?

2.when I run the following command in /app/node_modules/.bin

./node-inspector --web-port=9090

**I got error: ** /usr/bin/env: node: No such file or directory any idea ? I guess it's related to the first issue...

We are working on CF version 2.74


回答1:


From the docs...

If you want the environment of your interactive SSH session to match the environment of your buildpack-based app, with the same environment variables and working directory, run the following commands after starting the session:

export HOME=/home/vcap/app
export TMPDIR=/home/vcap/tmp
cd /home/vcap/app
[ -d /home/vcap/app/.profile.d ] && for f in /home/vcap/app/.profile.d/*.sh; do source "$f"; done
source /home/vcap/app/.profile

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html#ssh-env

These instructions are generic though, for the Node.js build pack you could simply run HOME=/home/vcap/app source $HOME/app/.profile.d/nodejs.sh since there's only one file to source from the build pack. Then optionally source the .profile, if your app has one and you need / want to include it.

Also, as the docs mention you should take a look through all .profile and .profile.d/*.sh scripts before running them to make sure there are no unintended side effects.

UPDATE:

A slightly easier way to do this is to run cf ssh myapp -t -c "/tmp/lifecycle/launcher /home/vcap/app bash ''". This will open a bash shell and it lets the lifecycle launcher handle sourcing & setting up the environment.




回答2:


I would suggest to read this piece of the Bluemix documentation on Application Management. It has sections for Liberty and Node.js apps. For Node.js it explains how to enable the inspector.

For the specific question: The node executable that you are looking for is under /app/vendor/node/bin. So the command would be:

export PATH=$PATH:/app/vendor/node/bin


来源:https://stackoverflow.com/questions/42978007/debug-nodejs-app-in-cf

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