简体   繁体   中英

how do i debug a node.js app using heroku foreman?

i am new to heroku and node.js. i have a small node.js app which i can start and run successfully on my local machine using FOREMAN from the heroku toolbelt. i do not understand how to best debug the app, though.

i see that there is an eclipse debugger for node.js as well as the node-inspector project. but i cant seem to make these work with FOREMAN.

foreman start

if it is not possible to debug an app started by foreman, what is the purpose of foreman?

Just an addition, your Procfile could look like this:

web: node web.js
webDebug: node --debug-brk=5858 web.js`

So to start debugging you just call foreman start webDebug , you could call the configuration however you want.

The debugger will listen on port 5858 and you'll have to call your app from http://localhost:5100 instead of http://localhost:5000 .

The purpose of Foreman is to allow you to run complex applications, which may consist of several processes, easily. Check out the author's blog post on Foreman :

Lately I've noticed my web apps are getting complicated to run. My apps no longer consist of a single web process; I usually have have one or more types of background workers to run different types of jobs and a clock process to handle scheduling. Splitting an app up in this way is great for performance and scalability. The downside, however, is that it becomes much more complicated to get the app and all of its parts running.

Foreman is an attempt to make this easier. Using foreman you can declare the various processes that are needed to run your application using a Procfile.

By leveraging Foreman, Heroku has made it so that you can essentially run any kind of process you want to--a Rails app, a Sinatra app, a Node.js app, or anything else--simply by specifying how to start it in your Procfile , which Foreman reads and executes.

Foreman also allows you to take this simple Procfile and export it to production environments using tools like Upstart and Init. It does not provide any debugging functionality (nor is it meant to).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM