How do I deploy the NodeJs Web app after the test is complete? Introduction to two good solutions
The following scenarios are known:
I'm going to configure this project for "Kenniu".
Its entry file is in "/path/to/entry.js".
Both the user and group running are Mrken
node is installed in the/usr/bin/node
The listening port is 2589.
Then look at these two options separately.
One | FISRT
Scenario One: configure system,24 hours to stay online
Complete the above operation, very simple.
Start: sudo systemctl start Kenniu
In addition to start, you can stop, restart, and Status View status (viewable when an error occurs). In addition, sudo systemctl enable Kenniu can be used to enable this service to boot automatically
Friendly test OK, very cool very good!
Advantages:
Simple configuration and low learning costs
Error auto Restart, 24 stay online (if the frequency is too high will be cut off, so the most reliable protection depends on monitoring)
Generic, not only CentOS support, other versions of Linux also support
Disadvantages:
Daini | Second
Scenario Two: Writing the service init script
cd/etc/init.d/or/etc/rc.d/init.d/
sudo vi kenniu, enter the shell script (later in detail)
sudo chmod +x kenniu
sudo chkconfig--add kenniu
Complete the above operation.
Start: sudo service start Kenniu
In addition to start, you can stop, restart, and so on.
The success of the test, but also very cool!
Scenario two script how to write
So far so simple, the hardest is left--how the script is written.
Its general framework, like the following pseudo-code, looks at annotations. Another click to get my full configuration, according to your situation, the above variable value can be used.
Advantages:
Disadvantages:
Need to learn some shell scripts
Not too general, seemingly centos, redhat, etc. to support, not very clear
This article is a leisure time, the former public number of articles moved to come.
"Server" under CentOS deployment run Nodejs Web App