Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Process monitoring tools Supervisor start MongoDB     - How to install PlayOnLinux 4.2.5 under Ubuntu 14.04 / 12.04 (Linux)

- Oracle 11g logical standby achieve BI needs (Database)

- Linux systems for entry-learning: Install closed-source packages in Debian (Linux)

- Simple RPM package production (Linux)

- Netcat Example (Linux)

- Ubuntu uses the / etc / profile file to configure the JAVA environment variable (Linux)

- Ubucompilator-Ubuntu, Debian, Linux Mint created deb package of graphical tools (Linux)

- How to contribute code to the GNU Project (Linux)

- Linux environment password security settings (Linux)

- How to install Ubuntu California - the calendar application (Linux)

- CentOS 5.10 installed Oracle 11G R2 (Database)

- httpd-2.4 feature (Server)

- How to release the cache memory on Linux (Linux)

- HomeKit User Interface Guidelines (Linux)

- Docker container plaintext password problem-solving way (Server)

- Security Configuration SQL Server 2000 database tutorial (Linux)

- The development environment to build Nodejs under Ubuntu 14.04 (Linux)

- Linux Security Raiders SSH tools SCP uses examples to explain in detail (Linux)

- Linux ldconfig command (Linux)

- C ++ Replication Control: Assignment operators and destructors (Programming)

  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 Security Raiders SSH tools SCP uses examples to explain in detail (Linux)
- How to clear the v $ archived_log view expiration information (Database)
- ssh using scp: / directory: Permission denied (Server)
- Performance Optimization: Using Ramlog transfer log files to memory (Linux)
- C ++ multithreading and critical resource instance (Programming)
- QEMU image file used: qcow2 and raw (Linux)
- Understand ASP.NET 5 running the command: DNVM, DNX, and DNU (Server)
- How to use nmap command in Linux (Linux)
- Manual cleaning Oracle audit records (Database)
- JavaScript basic tools list (Programming)
- Linux system started to learn: how to view the contents of the seed on the Linux file (Linux)
- grep, egrep and regular expressions (Linux)
- To delete the directory and all specified files under the Mac (Linux)
- Linux atomic operations and synchronization mechanisms (Programming)
- crontab task scheduling Health Check (Linux)
- Android project using the command to create and install the package (Programming)
- Linux system commands to view hardware information (Linux)
- MongoDB replication instance (Database)
- FastDFS installation and deployment (Server)
- Eclipse distributed management using GitHub project development (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.