Monday, 24 April 2017

NodeJS: need to obtain reference to existing server or to close it

Ok - so there is something I am unable to find and I feel might be fairly simple. I created a server but forgot to capture the reference sent back in a variable.

http.createServer(function (request, response) {
    // Send the HTTP header
    // HTTP Status: 200 : OK
    // Content Type: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});

    // Send the response body as "Hello World"
    response.end('Hello World\n');
 }).listen(8081);

Now I am trying to close the server but i don't have a reference to the server. Is there any way to obtain the reference or close the http server from the nodejs interpreter to avoid using taskmanager to kill the process. Working on Win 7 NodeJS interpreter.



via ManFriday

No comments:

Post a Comment