流星:在服务器端调试 [英] Meteor: Debug on server side

查看:83
本文介绍了流星:在服务器端调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道调试服务器端代码的好方法吗? 我尝试启用Node.js调试,然后使用node-inspector,但是它不显示任何代码.

Does anyone know a good method to debug server side code? I tried enable Node.js debug then use node-inspector but it does not show any of my code.

我最终使用console.log,但这效率很低.

I end up using console.log but this is very inefficient.

更新:我发现以下过程可在我的Linux机器上运行:

  1. 运行Meteor时,它将产生两个进程

  1. When you run Meteor, it will spawn two processes

process1:/usr/lib/meteor/bin/node/usr/lib/meteor/app/meteor/meteor.js

process1: /usr/lib/meteor/bin/node /usr/lib/meteor/app/meteor/meteor.js

process2:/usr/lib/meteor/bin/node/home/paul/codes/bbtest_code/bbtest02/.meteor/local/build/main.js --keepalive

process2: /usr/lib/meteor/bin/node /home/paul/codes/bbtest_code/bbtest02/.meteor/local/build/main.js --keepalive

您需要在process2上发送kill -s USR1

You need to send kill -s USR1 on process2

运行节点检查器,您可以看到服务器代码

Run node-inspector and you can see your server code

我第一次尝试时,将/usr/lib/meteor/bin/meteor中的流星启动脚本的最后一行修改为

On my first try, I modify the last line on meteor startup script in /usr/lib/meteor/bin/meteor to

exec "$DEV_BUNDLE/bin/node" $NODE_DEBUG "$METEOR" "$@"

并在命令提示符下运行NODE_DEBUG=--debug meteor.这仅将--debug标志放在process1上,因此我只能在node-inspector上看到流星文件,而找不到我的代码.

and run NODE_DEBUG=--debug meteor on command prompt. This only put --debug flag on process1 so I only see meteor files on node-inspector and could not find my code.

有人可以在Windows和Mac计算机上检查吗?

Can someone check this on Windows and Mac machine?

推荐答案

在流星0.5.4中,这变得容易得多:

In Meteor 0.5.4 this has become a lot easier:

首先从终端运行以下命令:

First run the following commands from the terminal:

npm install -g node-inspector
node-inspector &
export NODE_OPTIONS='--debug-brk'
meteor

然后在浏览器中打开http://localhost:8080以查看节点检查器控制台.

And then open http://localhost:8080 in your browser to view the node-inspector console.

更新

从Meteor 1.0开始,您只需输入

Since Meteor 1.0 you can just type

meteor debug

本质上是上述命令的快捷方式,然后按照所述在浏览器中启动节点检查器.

which is essentially a shortcut for the above commands, and then launch node inspector in your browser as mentioned.

更新

在Meteor 1.0.2中,添加了一个控制台或外壳.在服务器上输出变量并运行命令可能会很方便:

In Meteor 1.0.2 a console or shell has been added. It may come in handy to output variables and run commands on the server:

meteor shell

这篇关于流星:在服务器端调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆