Home>Article>Web Front-end> How to restart service in nodejs

How to restart service in nodejs

青灯夜游
青灯夜游 Original
2022-01-25 14:33:10 7113browse

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.

How to restart service in nodejs

The operating environment of this tutorial: linux5.9.8 system, nodejs version 12.19.0, DELL G3 computer.

How to restart the Node service

1. Press Ctrl C in the command console to terminate the currently running code

2. Then continuenode filename.js, you can restart node.js


Automatically restart the Node service

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.

Installsudo npm install supervisor -g, or usesudo 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn