NodeBB development environment (IDE - Tools - Configs etc)
-
Sorry for bumping this up, but i haven't managed to get any of the suggested debug tools working with nodebb.
Has someone managed to use them recently? Any help?
Thanks!
-
So, I hope I'm not speaking too soon, but this should get you guys up and running (OSX Yosemite)
So far what I've done is:
-
upgrade to node 0.12.5 (0.12.x should be sufficient)
- I'm not sure if this is necessary. I did it because I read that there's better support for debugging clustered apps due to the way it passes the debug port to child processes, but it still wasn't working for me using most of the tutorials on the internet
-
install node-inspector
-
if like me you had already installed node-inspector and nodeBB prior to upgrading to node 0.12.x, you'll have to rebuild your node packages:
- in your NodeBB root directory, run
npm rebuild
- in your node-inspector root dir, also run
npm rebuild
- I installed node-inspector through npm, (
npm install -g node-inspector
) so I had to go to/usr/local/lib/node_modules/node_inspector
and runnpm rebuild
- I installed node-inspector through npm, (
- in your NodeBB root directory, run
-
Start nodebb in development mode: (in NodeBB root dir):
./nodebb dev
- this starts up only one fork so you don't get the EADDRINUSE error
-
In a new terminal, run
node-inspector &
(spins up as a background process, so if something goes wrong, useps aux | grep node-inspector
to find the pid and kill it)-
this will output something like
Visit http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 to start debugging.
-
-
Press enter to get back to the command line
-
Type
ps aux | grep app.js
:brian 79177 0.0 0.0 2432772 660 s006 R+ 10:03PM 0:00.00 grep app.js brian 79089 0.0 1.1 3763608 183804 s005 S+ 9:41PM 0:04.91 /usr/local/Cellar/node/0.12.5/bin/node app.js
-
the pid for NodeBB is 79089 in my case, so I just send a
kill -s USR1 79089
and you should see this in the terminal where you spun up ./nodebb dev:Starting debugger agent. Debugger listening on port 5858
-
Go load the address you got from node-inspector in your browser ^ (it might take a second to load)
-
Set a breakpoint somewhere (that you know how to hit) and you should be up and running!
-
Now you can also just ctrl-C to quit the nodeBB process. If you want to start it again:
- Start
./nodebb dev
again - Use
ps aux | grep app.js
to find the pid again - Since node-inspector is still running in the background, you just have to send a
kill -s USR1 <pid>
to the new pid of the running nodebb instance, and refresh the browser window that had the debugger open originally
- Start
-
-
@BDHarrington7
I am in need of stepping through the spin-up process (loading plugins). Have you tried something like that?My next step would be to figure out if we can start the debugger agent somewhere in
nodebb
orloader.js
, before the worker is forked off.Everything still very vague though. I'm new to this debugging thing. Up until now console.log always was enough. Currently, I'm fiddling with gdb, which strikes me as being a bit over the top.
-
I haven't found a good solution to that, unfortunately. It seems like the node-inspector has to load the files first before it can pause the program, so you'd have to pause the program first before loading node-inspector... I'd have to play around with it some more
-
this command makes it a little easier to send the USR1 signal to the process:
kill -s USR1 `ps aux | grep app.js | grep -v grep | awk '{ print $2 }'`
-
@BDHarrington7
Use pgrep/pkill!kill -s USR1 $(fgrep -f "app.js")
or even shorter with pkill
pkill -USR1 -f "app.js"
Substitute
-USR1
with-SIGHUP
and you got yourself a quick and easy build-tool command to restart NodeBB, when changing files.
(I'm using SublimeText / Atom)