Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Process monitoring tools Supervisor start MongoDB     - C ++ multithreading and critical resource instance (Programming)

- Piostat - Monitoring and Statistics Linux process (Linux)

- Docker data container protection the pros and cons (Server)

- Linux user status query, and to unlock locked user (Linux)

- Use Oracle Data Guard to complete cross-platform database migration cases (Database)

- Android memory optimization of the memory cache (Linux)

- VMware virtual machine can not start VMnet0 no Internet access and other issues (Linux)

- MySQL development common query summary (Database)

- Kubuntu 14.04 desktop to the user how to upgrade KDE 4.13.2 (Linux)

- MySQL full-index scan bug (Database)

- Firewall - Internet Militarization (Linux)

- CoreOS use register mirror to build private warehouse (Linux)

- How to Set Free SSH password on CentOS / RHEL (Linux)

- Python implementation restart the router (Programming)

- Oracle EBS R12 for Linux installation (Database)

- Java call by value and by reference (Programming)

- Ubuntu resolve sudo: source: command not found error (Linux)

- Ubuntu 15.04 install Complete Guide (Linux)

- Linux Network Statistics Tools / Command (Linux)

- Linux garbled file delete method (Linux)

  Process monitoring tools Supervisor start MongoDB
  Add Date : 2018-11-21      
  A,what is a supervisor

Superviosr is the process on a UNIX-like system monitoring tools. Supervisor is a Python developer of client / server system that can manage and monitor * nix above process. However, like daemontools, it can not monitor the daemon process

Official website: http: //supervisord.org/

B,why use two supervisor

 Deployment is simple: Why simple? Because when we usually manage linux process, in general, we need to write your own script process to achieve a start / stop / restart / reload function, and then thrown into /etc/init.d/ below. There are many good places to do so, first we have to write the script, which is a very time-consuming. Second, when the process hang time, linux does not automatically restart it, you want to automatically restart, then we need to write a script to restart the monitor. And, supervisor can be the perfect solution to these problems. Well, how to solve it, in fact, supervisor management process, is through the fork / exec the way these processes are managed, as a supervisor of the child process to start. In this case, as long as we in the supervisor's configuration file, the path you want to manage the process executable file written opinions OK. This will save us as linux management process when the write control script trouble. Second, the management process as a subprocess supervisor when the child process hang when the parent can get the child to hang accurate information, so of course it can hang on the child process to automatically restart, of course, restart or not restart, it also depends on your configuration file there are wood have set autostart = true, this is something.

Centralized management: supervisor management process, process group information, all written in a ini file format was OK. And, when we manage supervisor can be managed locally or remotely manage and supervisor provides a web interface, we can be on the web interface to monitor, manage processes. Of course, local, remote, and when the web management interface to call the supervisor of xml_rpc, this is something.

supervisor management process, process group information, all written in a ini file format was OK. And, when we manage supervisor can be managed locally or remotely manage and supervisor provides a web interface, we can be on the web interface to monitor, manage processes. Of course, local, remote, and when the web management interface to call the supervisor of xml_rpc, this is something.


Why say it accurate? Because linux feedback on the state of the process, sometimes less accurate. Why is not accurate? The landlord does not know ah, official documents is to say, tell the landlord knows about it, appreciate it. The supervisor monitoring the child process, the child process state was undoubtedly accurate.

Process group

supervisor can set the unified management of the process, that is to say we need to manage the process can be written to a group inside, and then we have this group as a managed object, such as start, stop, restart, etc. operations. The linux system is no such function, we want to stop a process, only one by one to stop, or to write their own scripts to batch is stopped.


Everyone knows that linux process, especially the process of listening ports under 1024, under the general user in most cases, can not be controlled. Want to control it, you must have root privileges. The supervisor provides a function for supervisord or each child, set a non-root user, the user can manage it corresponds to the process.

But this function, do not see everyone with their environment a

C,supervisor Structure

Supervisord: main process responsible for managing the process server, it creates a configuration file to specify the number of child processes applications throughout the life cycle management of the child process, the process of crash restart, changes to the process to send event notification. While built-in web server and XML-RPC Interface, easy process management.

Supervisorctl: management client, through the command line to send a message to supervisord, you can view the process status, load profiles, start and stop the process, view the process standard output and error, remote operation.

Web server: superviosr provides web server functionality available through web control process.

XML-RPC interface: XML-RPC interface that provides XML-RPC services sub-processes management, monitoring

D, installation and deployment

In order to unify python and various versions of dependent libraries, instead of the system recommended python pyrun be deployed, and the need to install pip in pyrun, to download the installation package pkg directory, run the following command:

/ Data / pyrun / bin / pip install --no-index -f pkg meld3 == 1.0.0

/ Data / pyrun / bin / pip install --no-index -f pkg elementtree == 1.2.6-20050316

/ Data / pyrun / bin / pip install --no-index -f pkg supervisor == 3.2.0

If the machine can not be networked, you can install the source code:

1) dependent python, python version can be upgraded

2) require third-party packages meld3, setuptools, ElementTree

setuptools (latest) from http://pypi.python.org/pypi/setuptools.

meld3 (latest) from http://www.plope.com/software/meld3/.

elementtree (latest) from http://effbot.org/downloads#elementtree.

3) root extract the related packages, batch installation.

E, configuration

Supervisor configuration file named supervisord.conf, it supervisord (Supervisor main service command) and supervisorctl (Supervisor monitoring and management commands) to provide a configuration option. Supervisor does not require the storage location of the configuration file supervisord.conf, Supervisor service startup by default in:

$ CWD / supervisord.conf
$ CWD / etc / supervisord.conf
These directory locations to find the configuration file supervisord.conf.

Supervisor also provide parameters "-c" to specify the directory path to the configuration file.
Terminal input "echo_supervisord_conf" command to view the contents of the default configuration of the Supervisor.

Generates a default configuration file:

echo_supervisord_conf> /etc/supervisord.conf

supervisor relatively simple configuration, the following configuration items to meet basic needs, more configuration items, please refer to the official configuration instructions

nodeamon = false # deamon way to start the process

[Supervisorctl] # system default configuration items

Port and user password [inet_http_server] #web management page
port = 8080

username = user

password = pwd

[Rpcinterface: supervisor] # xml-rpc Interface configuration
supervisor.rpcinterface_factory = supervisor.rpcinterface: make_main_rpcinterface

[Program: mongodb]

command = / data1 / mongodb_2.4.7_build / mongod -config /data1/mongodbrs/config/mongodb.conf --directoryperdb --quiet --profile 1 --slowms 1000 --noprealloc --shardsvr

directory = / data1 / mongodb_2.4.7_build

autostart = false

user = root

Note that the default configuration file last few lines

You can add a directory within supervisord.d at supervisord.conf file in the same directory .ini configuration file separately


files = supervisord.d / *. ini

Note: The process being monitored to run in non-daemon mode to mongodb, for example, need to remove mongodb process startup command parameters in the --fork


# Start supervisor

  python / usr / bin / supervisord

# Boot process monitoring

    supervisorctl start all

# Shutdown process monitoring

      supervisorctl stop all

# Check status

      supervisorctl status

# Reload the configuration file:

supervisorctl reload

In fact, by supervisorctl supervisor can open a command line console, and then enter the watch can be viewed with the help of the command, and then help + command to view the specific features of each command

G, web control

Arranged in supervisord.conf in [inet_http_server],


port = #IP and bound port

username = admin # Name Administrator

password = 123456 # administrator password

Thus, the input configuration write address and port number in the browser, enter the configured username and password, you can see the web-based console interface. From this, you can look supervisor monitoring> information, you can view logs and other processes.

Browser to: http: // 8080 /, (where IP supervisor for the deployment of IP)

H, Monitoring Alarms

If demand is automatically pulled crash process, through the command line to manage the process, more than enough content. supervisor 3.0 version introduces event, we take advantage of this feature to achieve real-time monitoring process status and alarms.

First, look at the event supervisor provided, supervisor of the child process through application management, monitoring program also runs as a child process, stdin child process, stdout, stderr have been redirected. Event processing is as follows:

Listener as a child process of writing to stdout READY \ n
When an event occurs, supervisor in the Ready state will choose a child process stdin written to the event content
Write OK \ n or FAIL \ n after the event is completed child process to handle stdout, feedback results
Repeat the above operation
Various types of events supervisor provided, comprising: a process status event, supervisor state event, timed events, xmlrpc call the event, the process log events, and so on. We focus on the process of state-related events. supervisor of the process is defined as a state in each state switch will trigger the corresponding event.

Monitoring program can use any language, as long as supervisor of the agreement properly formatted event messages can be processed. Recommended use python as the monitoring program, supervisor module provides a childutils handler makes writing easier.
- Linux SU command security Suggestions (Linux)
- Ubuntu 15.10 How to install TeamViewer 11 (Linux)
- Ubuntu 14.04 can be used to create a WIFI hotspot for Android (Linux)
- Implicit conversion from Java type conversion compare MySQL and Oracle (Database)
- Oracle online redefinition (Database)
- C language Bubble Sort - integer sort (Programming)
- Ubuntu security settings and tools (Linux)
- How to import JNI resulting .so libraries in Android Studio (Programming)
- A deep understanding of Java enum (Programming)
- Can not empty the Recycle Bin to repair problems in Ubuntu 14.04 (Linux)
- Linux nice program origin of the name (Linux)
- Ubuntu upgrade to Linux Kernel 4.2.3 Kernel (Linux)
- Vi editor Introduction (Linux)
- There is sort of a directed acyclic graph topology (Programming)
- Java reflection summary (Programming)
- Kali Linux 2.0 U disk installation errors Your installation cd-rom could not be mounted (Linux)
- Java 8 stream parsed into SQL (Programming)
- Hazelcast integration with MongoDB (Database)
- Installation Eduspec university management systems 17 Linux Mint (Server)
- Linux port mapping system (routing and forwarding) (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.