简体   繁体   English

我如何使用heroku工头调试node.js应用程序?

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

i am new to heroku and node.js. 我是heroku和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. 我有一个小node.js应用程序,我可以使用来自heroku工具带的FOREMAN在我的本地计算机上成功启动和运行。 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. 我看到node.js和node-inspector项目都有一个eclipse调试器。 but i cant seem to make these work with FOREMAN. 但我似乎无法使这些与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: 另外,您的Procfile可能如下所示:

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. 因此,要开始调试,只需调用foreman start webDebug ,您可以根据需要调用配置。

The debugger will listen on port 5858 and you'll have to call your app from http://localhost:5100 instead of http://localhost:5000 . 调试器将侦听端口5858,您必须从http:// localhost:5100而不是http:// localhost:5000调用您的应用程序。

The purpose of Foreman is to allow you to run complex applications, which may consist of several processes, easily. Foreman的目的是允许您轻松地运行复杂的应用程序,这些应用程序可能包含多个进程。 Check out the author's blog post on Foreman : 查看作者关于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. Foreman试图让这更容易。 Using foreman you can declare the various processes that are needed to run your application using a Procfile. 使用foreman,您可以使用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,Heroku已经做到了这样,你可以基本上运行你想要的任何类型的进程--Rails应用程序,Sinatra应用程序,Node.js应用程序或其他任何东西 - 只需指定如何启动它你的Procfile ,Foreman读取和执行。

Foreman also allows you to take this simple Procfile and export it to production environments using tools like Upstart and Init. Foreman还允许您使用这个简单的Procfile并使用Upstart和Init等工具将其导出到生产环境。 It does not provide any debugging functionality (nor is it meant to). 它不提供任何调试功能(也不是意味着)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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