Just installed nodeJS and NPM and nodesupervisor via Terminal in OS 10.5.8.
I have a server running with:
var http = require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.w开发者_运维技巧rite("Hello World!");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
How do I restart the server, without quitting Terminal if the following is updated:
response.write("Hello World, From NodeJS!");
I've seen this "^C" used in Terminal, in a NodeJS video TUT.
Also have node supervisor which appears to handle these changes, but when I attempt to use the watch "-w" command(supervisor -w server.js), on server.js, nothing ("file being watched" or something) is returned, and the supervisor help screen simply reloads.
NPM: 1.0.96 nodeJS: v0.4.11
Ctrl-C is definitely the way to quit node without quitting terminal all together, just like most command-line apps.
A better option for you might be nodemon. It is specifically for restarting node when changes to files are made.
To install:
npm install nodemon -g
Then simply execute your app with nodemon instead of node.
nodemon server.js
How did you start the node server?
If you are using supervisor then you should be able to do the following:
supervisorctl stop all
Afterwards do whatever you did before to start the thing back up:
supervisord
精彩评论