debugging child processes in node

Source: Internet
Author: User

Now node. JS is doing the best in single-step debugging, counting IntelliJ idea, but node cannot start debugging when using cluster, and StackOverflow has a description and answer to this question (click here to see). But the solution here is to implement debugging by increasing the startup parameter control and abandoning the multi-process mode, such as starting a single process at local testing and using multiple processes in an operational environment.

You can read environment variables in node. js by using process.env.环境变量名 the method, which means that you can control whether multiple processes are enabled in the following ways:

if (process.env.DEBUG_LOCAL == ‘true‘) {    //单进程代码处理} else {    //cluster代码处理}

Code 1.1

The rest is to configure the environment variables in idea, click the Debug Configuration function, that is, click on the figure 1.1 position.

Figure 1.1 Selecting a configuration

Click the environment Variable Configuration function button in the Open interface

Figure 1.2 Configuration Interface

Add an environment variable

Figure 1.3 Adding environment variables

This completes the configuration, after clicking Debug, will run the current code into a single process, in the production environment without the environment variable start, then run into the normal cluster code.

debugging child processes in node

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.