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 command 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.
You 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:
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 command 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:
forever list
tail -f <log file path>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.