Home  >  Article  >  Web Front-end  >  How to use node.js to start running in the background forever

How to use node.js to start running in the background forever

php中世界最好的语言
php中世界最好的语言Original
2018-05-24 09:29:101571browse

This time I will show you how to use node.js to start running forever in the background and use node.js to start running forever in the background. What are the precautions? The following is a practical case. Let’s take a look.

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

or

node index.js
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
Then save and change the suffix to bat

However, this is After startup, the cmd box is always there. If

exit, the node.js project will be closed.

At this time we need to use forever

##1 .First switch to the project directory

cd 你的项目路径

2.ThenInstall##

npm install forever -g

3. Start

forever start app.js

4. Close

forever stop app.js #关闭
I believe you have mastered it after reading the case in this article For more exciting methods, please pay attention to other related articles on the php Chinese website!

Recommended reading:

vue Nested Routing and 404 Redirect Implementation Method Analysis_vue.js


How to use Internationalization of your own js code

The above is the detailed content of How to use node.js to start running in the background forever. 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