Register the nodejs program as a windows Service

Source: Internet
Author: User
Before I run the nodejs program, I entered a similar command in the cmd command to start: nodeD: \ NodeJs \ demo_express \ microblog \ app. after the jscmd command is disabled, the nodejs program is also automatically closed. In the production environment (Development and debugging programs), this method can fully meet the requirements... before SyntaxHig, if I run the node. js program, I entered a similar command in the cmd command to Start node D: \ nodejs \ demo_express \ microblog \ app. after the jscmd command is disabled, the nodejs program is also automatically closed. In the production environment (Development and debugging programs), this method can fully meet the needs, but in the release environment, it is best to configure as a service, in this way, you can avoid adverse consequences caused by server restart, illegal window shutdown, and other reasons. The following are two solutions I have tried: 1. save the cmd command in the bat file and add the bat file to the program. Advantages: easy to implement and easy to understand. Disadvantage: Although nodejs can be started after the server is restarted, the node. js program will be automatically closed if it is closed illegally due to a cmd command window running, therefore, this method is temporary. 2. windows Service Mode advantages: Not afraid to restart, there is no cmd command window disadvantages: Implementation is relatively complicated, not easy to understand implementation steps: 1> Create a bat file named run. bat, enter node D: \ NodeJs \ demo_express \ microblog \ app. js (modify the command as needed) and save it. 2> Create a service. Refer. register the js program as a windows service and set the Application attribute in step 1 to the path where the bat file is located. find the service in the windows Service list, make sure that the Startup type is automatic, and then click Start. The cmd command box is not found. After logging out on your computer and logging on again, you will find that the service can be started normally and the nodejs program can run normally. This indicates that the service is successfully configured.
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.