How to forcibly keep a Node.js process from terminating?

前端 未结 3 1610
清歌不尽
清歌不尽 2020-12-23 17:11

TL;DR

What is the best way to forcibly keep a Node.js process running, i.e., keep its event loop from running empty and hence keeping the process from terminating?

3条回答
  •  情深已故
    2020-12-23 18:06

    I'll throw another hack into the mix. Here's how to do it with Promise:

    new Promise(_ => null);
    

    Throw that at the bottom of your .js file and it should run forever.

提交回复
热议问题