How can I restart a Node.js app from within itself (programmatically)?

后端 未结 5 2321
余生分开走
余生分开走 2020-12-15 06:14

How can I create an app that can restart itself? I want to create an app that sets up a web-admin which can restart itself. Is this possible? If so, how? I was thinking this

5条回答
  •  被撕碎了的回忆
    2020-12-15 06:42

    1. you can run your app using child process and manipulate it how needed: https://nodejs.org/api/child_process.html

    2. use forever, pm2 or whatever thing to restart after death and kill itself with process.exit() https://nodejs.org/api/process.html

提交回复
热议问题