Home > Article > Web Front-end > How to restart service in nodejs
Nodejs method to restart the service: 1. Press the "Ctrl C" key in the command console to terminate the currently running code; 2. Execute the "node filename.js" command to restart the node service.
The operating environment of this tutorial: linux5.9.8 system, nodejs version 12.19.0, DELL G3 computer.
1. Press Ctrl C in the command console to terminate the currently running code
2. Then continuenode filename.js
, you can restart node.js
Node Supervisor was originally used to automatically restart the Node.js application on the server when it crashes. Of course, it can also monitor changes in your project's js files and automatically restart to facilitate debugging.
Install sudo npm install supervisor -g
, or use sudo cnpm install supervisor-g
.
Usage:
1. Turn off the previously opened node service.
2. Then use the command: supervisor yourApp.js in the project path to open Supervisor. It will start the node service and continuously detect file changes. When the content of the JS file is modified, the service will be automatically restarted, which is very convenient.
For more node-related knowledge, please visit: nodejs video tutorial!
The above is the detailed content of How to restart service in nodejs. For more information, please follow other related articles on the PHP Chinese website!