I have a ubuntu server, on which node js app is running. That app is developed from Sails mvc framework. I am asked to fix some server side js code. But the problem is I don't how to test, and debug those code.
First of all, it's linux server without UI, I can't test from browser by localhost, since the program is triggered from HTTP request.
Secondly, it is also unlikely to debug from build-in debugger mand line client, for the same reason as the first one. Maybe I just don't know how...
Third, I saw there is some console.log('...') codes, but I don't know where to find the log file.
Hopefully someone could provide some opinions. Thanks very much.
I have a ubuntu server, on which node js app is running. That app is developed from Sails mvc framework. I am asked to fix some server side js code. But the problem is I don't how to test, and debug those code.
First of all, it's linux server without UI, I can't test from browser by localhost, since the program is triggered from HTTP request.
Secondly, it is also unlikely to debug from build-in debugger mand line client, for the same reason as the first one. Maybe I just don't know how...
Third, I saw there is some console.log('...') codes, but I don't know where to find the log file.
Hopefully someone could provide some opinions. Thanks very much.
Share Improve this question edited Apr 3, 2015 at 23:04 Travis Webb 15k9 gold badges59 silver badges111 bronze badges asked Jan 7, 2015 at 9:09 user2321728user2321728 1,3732 gold badges12 silver badges17 bronze badges3 Answers
Reset to default 2You don't need the browser - you can do fake requests with curl
:
curl -v -XPOST localhost/path -d 'variable=test'
Probbably your app has some logging (logs are saved to a file), so search for it:
search for the node process PID:
ps aux | grep node
or
ps aux | grep <your application name>
view open files of the node process and find your logs
ls -l /proc/<node_app_pid>/fd
Resources:
- List Open Files for Process
Sails has it's own built in test suite, using mocha.
See the Sails documentation on how to test and debug your application.
NodeJS exists outside your browser, as a standalone runtime, so it does not log to your chrome dev console. A node app is started from the terminal using the mand node <filename.js>
or nodejs <filename.js>
. Since you mentioned sails, maybe you are running it as a forever
process
To check if you are running it as forever process:
- Open linux terminal on the server that the app is running on.
- type
forever list
- Find the entry containing the name of your main file
- Then get the name of the .log file associated with it
- To see the logs do
tail -f <log file path>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745375421a4624975.html
评论列表(0条)