Never mind. The reason this did not work: I forgot to meteor reset
so debugger
did not get a chance to stop. Duh!
More info: I am using the method in the answer by Mason Chang to the related question, not the kill -s USR1 [proc_id]
(where I could see the scripts, but not able to stop in the startup() function.). Also, I am using meteorite.
I am trying to debug the Meteor.startup(function ()) code on Meteor server side (i.e., under /server
) with node-inspector, I have read this question, and following the answer to change run.js
, but somehow, my own script for the startup function does not show up in the scripts section of Chrome.
How do I see my code here and set break points and stop at those points? BTW, the Meteor_debug() does not output anything to stdout, stderr, or node-inspector browser console. I also tried console.log() with no avail. How to enable logging on Meteor server side?
If it matters, I am on auth
branch.
The code here is very simple (/server/bootstrap.js):
Meteor.startup(function () {
if (Logs.find().count() === 0) {
var data = [/*...some data...*/];
var timestamp = (new Date()).getTime();
Meteor._debug("timestamp: "+timestamp+", data.len: " + data.length);
debugger;
for (var i = 0; i < data.length; i++) {
data[i].timestamp = timestamp++;
var entry_id = Logs.insert(data[i]);
Meteor._debug("entry_id: "+ entry_id);
}
}
});
Now that I know how to do this, I will answer my own question so that we can keep this information (in details) here: (This is based on Mason Chang's answer to this question.)
/usr/lib/meteor/app/meteor/run.js
(or the corresponding run.js
installed by meteorite in HOME//.meteorite/meteors/meteor/meteor/[LONG_HEX_CODE]/app/meteor
):[path.join(bundle_path, 'main.js'), '--keepalive']
['--debug-brk', path.join(bundle_path, 'main.js'), '--keepalive']
debugger
statements as breakpoints in your server code;node-inspector &
in a server terminal. (google "node-inspector" to install it.)node-inspector
.)main.js
in your [PROJECT_DIR]/.meteor/local/build
);debugger
statements are, you may have to do some triggering actions in client browser window to run to the debugger
breakpoints. (Note that if you wait too long to hit the RUN button, your client window may time out, and you have to refresh again.)Edit: For logging on server side, you can use either Meteor._debug() and console.log(), they will show up in the terminal where you run meteor
. On client side, these logging statements will output to the console of your browser's dev. tools.
On MacOSX, you can use with Chrome :
NODE_OPTIONS="--debug-brk" meteor
and in another terminal
node-inspector --debug-port=5858 --web-port=12345
Then connect Chrome to 127.0.0.1:12345/debug?port=5858
Otherwise with Webstorm, just create a Node.js Remote Debug configuration and run it :
Name : Meteor Host : 127.0.0.1 Port 5858
Note that once the server has started, you need to press run in order for Meteor to load, and then pause in order to debug from the server console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With