Home > Web Front-end > JS Tutorial > Node.js method to start running forever in the background

Node.js method to start running forever in the background

不言
Release: 2018-07-04 10:50:18
Original
1840 people have browsed it

Today I will share with you a node.js deployment method to start running forever in the background. It has a good reference value and I hope it will be helpful to everyone.

We know that if you want to run the project after deployment, you need to use the command line

cd to the project directory and then execute

npm install
Copy after login

or

node index.js
Copy after login

Or use a bat file to execute

The method is to first create a txt file and write down the steps you need to perform

cd C:\Program Files\nodejs\wh
npm start
Copy after login

Then save and change the suffix to bat

However, this is After startup, the cmd box is always there. If you exit, the node.js project will be closed.

At this time we need to use forever

1. First switch to the project directory

cd 你的项目路径
Copy after login

2.Then install

npm install forever -g
Copy after login

3.Start

forever start app.js
Copy after login

4. Close

forever stop app.js #关闭
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone’s study, more related content Please pay attention to PHP Chinese website!

Related recommendations:

How to use Buffer to encode and decode binary data in Node.js

About nodejs development environment Configuration and use

The above is the detailed content of Node.js method to start running forever in the background. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template