Python process management tool supervisor uses instances, pythonsupervisor

Source: Internet
Author: User

Python process management tool supervisor uses instances, pythonsupervisor

We usually write a script and put it in the background for execution. What should we do?
Copy codeThe Code is as follows:
Nohup python example. py 2> & 1/dev/null &

Tumx or screen? However, it may not work well. Today, let's look at a process management tool supervisor in python:

Said: Supervisor: A Process Control System

To put it bluntly, He is a demon program. He can help us complete the script or program we want to host, and take good care of it;

1. Installation

Python is well installed. If it is a centos series, you can use:
Copy codeThe Code is as follows:
Yum install supervisor

For the debin series:
Copy codeThe Code is as follows:
Apt-get install supervisor

Or simply click:
Copy codeThe Code is as follows:
Easy_install supervisor
Pip install supervisor

2. Create a configuration file

You can use the built-in tool echo_supervisord_conf.
It is created under/etc by default, but you need to have the root permission:
Copy codeThe Code is as follows:
Echo_supervisord_conf>/etc/supervisord. conf

Of course, it can also be another directory, but it must be specified at startup (-c)

3. Start Supervisor

Next, let's take a look at how to start supervisord and supervisorctl.

First, find a program to host, such as/bin/date.
Copy codeThe Code is as follows:
Vim/etc/supervisord. conf

[Program: test]
Command = python/root/test_supervisor.py
Process_name = % (program_name) s
Stdout_logfile =/root/test. log
Stderr_logfile =/root/test. log

Save and start:
Copy codeThe Code is as follows:
/Usr/bin/supervisord-c/etc/supervisord. conf

Sending signal:

It's so cool. Next, you can play it freely...
Http://supervisord.org/This is the official website.
At last, he can manage the interface, which also provides a way for us to manage processes on the interface!


How can I determine and kill a time-out python process?

Supervisord is dedicated to this. This is very mature, and the Python and MongoDB processes on the server are managed by it. If supervisord does not meet your needs, for example, you need to manage processes in your own program, you can refer to supervisord code implementation. Simple: You can use docs.python.org/library/subprocess.htmlto implement a set of features.
 
How can I determine and kill a time-out python process?

Supervisord is dedicated to this. This is very mature, and the Python and MongoDB processes on the server are managed by it. If supervisord does not meet your needs, for example, you need to manage processes in your own program, you can refer to supervisord code implementation.

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.