"Server" under CentOS deployment run Nodejs Web App

Source: Internet
Author: User

How do I deploy the NodeJs Web app after the test is complete? Introduction to two good solutions

The following scenarios are known:

    1. I'm going to configure this project for "Kenniu".

    2. Its entry file is in "/path/to/entry.js".

    3. Both the user and group running are Mrken

    4. node is installed in the/usr/bin/node

    5. The listening port is 2589.

Then look at these two options separately.

One | FISRT

Scenario One: configure system,24 hours to stay online

    • cd/etc/systemd/system/

    • sudo vi kenniu.service Enter the following configuration information

    • sudo chmod +x kenniu.service, plus executable permissions

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:

    • Not very flexible.

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:

    • Self-written script processing, very flexible, including each step to output what prompts can be controlled by themselves

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.