Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

debugging - Meteor: Debug on server side

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.

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

Update: I found the following procedure works on my Linux machine:

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

    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

  2. You need to send kill -s USR1 on process2

  3. Run node-inspector and you can see your server code

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" "$@"

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.

Can someone check this on Windows and Mac machine?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

Update

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.

Update

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...