How to restart a node.js server

后端 未结 9 1246
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 16:46

I\'ve installed and is running a node.js server on osx. I\'ve dled a chat module and is happily running it. I\'ve altered some pieces and need to restart the server to see t

9条回答
  •  暖寄归人
    2020-12-22 17:03

    If I am just run the node app from console (not using forever etc) I use control + C, not sure if OSX has the same key combination to terminate but much faster than finding the process id and killing it, you could also add the following code to the chat app you are using and then type 'exit' in the console whenever you want to close down the app.

    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    
    process.stdin.on('data', function(data) {
      if (data == 'exit\n') process.exit();
    });
    

提交回复
热议问题