Linux Process monitoring tool: Supervisor

Source: Internet
Author: User

Objective

We know that now the app backend service must be running reliably, we hope that if the SOA service process hangs and can be restarted quickly, then the process monitoring is needed, and the supervisor under Linux is the weapon of the management process. Supervisor is a set of common process management programs developed with Python that can turn a normal command-line process into a background daemon and monitor the status of the process, which can be restarted automatically when the exception exits. Consider, in fact, not only in the SOA services can be monitored, but also can provide services such as nginx any process monitoring and management.


Installing Supervisor

In the case of an offline installation, there are many pre-packaged installations, and a corresponding version, such as Python2.7, is required. If the Python version is low, it needs to be upgraded, and it is best to change it in a linked way instead of uninstalling the lower version completely.


Bloggers have been successful in practice, as follows: "Ignore JDK and Git"

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/84/41/wKiom1eKIs2w1nuJAAAsK9bcxfc346.png "title=" Sogou _ 2016-07-16_20-04-25.png "alt=" Wkiom1ekis2w1nujaaask9bcxfc346.png "/>

The package can be installed directly using the Python setup.py install.


Notice where the supervisor was installed? If not explicitly specified, is actually installed in the Python directory, because plainly is a Python module, as shown in:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/41/wKiom1eKI8nyaWYAAAB0mp7ro-0908.png "title=" Sogou _ 2016-07-16_20-08-39.png "alt=" Wkiom1eki8nyawyaaab0mp7ro-0908.png "/>


Here, we see the Supervisord,supervisord command, which is actually the 2 basic commands that are commonly used in a company.


After installation, the default base configuration is generated using the echo_supervisord_conf command, and there is a supervisord.conf under/etc.


We can probably take a glance at the typical segmented configuration:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/84/41/wKiom1eKJQHwXQYyAABrpooed2o473.png "title=" Sogou _ 2016-07-16_20-13-50.png "alt=" Wkiom1ekjqhwxqyyaabrpooed2o473.png "/>


In fact, generally in the company, we are involved in a lot of projects will be used to supervisor, we will not write all the configuration into a file, but according to the business each to provide their own configuration, and then include. You can look at an example:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/84/41/wKiom1eKJaWjqOG6AAAGSEsd-T4308.png "title=" Sogou _ 2016-07-16_20-16-34.png "alt=" Wkiom1ekjawjqog6aaagsesd-t4308.png "/>



Monitoring practices


First, provide the configuration file

We can provide the following content in/supervisor/etc/test.conf:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/84/41/wKioL1eKJmiC4pehAAAWVdiN68w273.png "title=" Sogou _ 2016-07-16_20-19-47.png "alt=" Wkiol1ekjmic4pehaaawvdin68w273.png "/>

Now that you want to give it to supervisor, then naturally tell her where your script path is, whether it starts with supervisor, and where the output log path waits for some basic information.

In addition, supervisor can help you start multiple processes at once, such as launching multiple SOA service instances on a single machine and managing them uniformly.

The above configuration is to tell supervisor to start 3 process instances, and the name of each instance is process_name. Which program_name is actually HelloWorld.


Second, start the Supervisord service

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/84/41/wKiom1eKKAPQM5mlAAAJ3UNz0YY364.png "title=" Sogou _ 2016-07-16_20-26-40.png "alt=" Wkiom1ekkapqm5mlaaaj3unz0yy364.png "/>

Tell the configuration file where it is, then start with Supervisord, and if you do not provide a profile path, it will be searched by the default path.


We can use PS to look under, what happened?

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/84/41/wKioL1eKKPDjnbTRAABEzrK1yFw701.png "title=" Sogou _ 2016-07-16_20-30-38.png "alt=" Wkiol1ekkpdjnbtraabezrk1yfw701.png "/>


Here, we see clearly the Supervisord service process, and the 3 instance processes she initiated for us.


Let's take a look at/myshell/supervisor4test.sh's content.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/84/41/wKioL1eKKcqCc1DOAAASG_O3S2Y035.png "title=" Sogou _ 2016-07-16_20-34-15.png "alt=" Wkiol1ekkcqcc1doaaasg_o3s2y035.png "/>


Let's take a look at the output of the log:


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/84/41/wKioL1eKKjmTI_pFAAANjXpIsM8454.png "title=" Sogou _ 2016-07-16_20-36-06.png "alt=" Wkiol1ekkjmti_pfaaanjxpism8454.png "/>


We clearly see that there are 3 processes at the same time in the output, which validates the above mentioned.


We can hang up a few of these 3 processes in a kill-9 way, and you'll find that supervisor will restart for us right away!


Third: Using SUPERVISORCTL for process management


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/84/41/wKiom1eKKt2zBBsoAABbRbzDWlA662.png "title=" Sogou _ 2016-07-16_20-38-51.png "alt=" Wkiom1ekkt2zbbsoaabbrbzdwla662.png "/>


Here, supervisor preliminary use of the introduction is complete, the following post some basic configuration instructions, for your reference.


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/84/41/wKiom1eKK-Djhf6nAABQMBGDrss826.png "title=" Sogou _ 2016-07-16_20-42-59.png "alt=" Wkiom1ekk-djhf6naabqmbgdrss826.png "/>


Good night!


This article is from the "Boundless Mind Infinite" blog, please be sure to keep this source http://zhangfengzhe.blog.51cto.com/8855103/1827020

Linux Process monitoring tool: Supervisor

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.