How to kill an open process on node.js?

前端 未结 5 1608
滥情空心
滥情空心 2020-12-07 16:53

I\'m trying to set up a build-system for Node.js on sublime, so I can press F7 to call \"node\" on the openned file. The problem is that the process is then open forever, so

5条回答
  •  失恋的感觉
    2020-12-07 17:33

    If sublime you say is sublimeText plugin, I have the same issue, and send TCP server a message 'shutdown' from python code, then

    app.js

     TCPserver
            .on('connection', function(socket)
            {
                socket.pipe(require('through')
                    (function(data)
                    { //----------------------------
                        if (data.toString() === 'shutdown')
                        {
                            process.exit();
                        }
                        //--------------------------
                    }));
                socket.end();
            })
    

提交回复
热议问题