安装Supervisor
easy_install supervisor
修改配置
echo_supervisord_conf > /etc/supervisord.conf
vim /etc/supervisord.conf
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
[inet_http_server]
port=*:9001
username=admin
password=admin
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /etc/supervisor/*.conf
添加脚本
vim /etc/supervisor/test.conf
[program:foo]
command=/bin/cat
启动Supervisor
supervisord -c /etc/supervisord.conf
启动Supervisorctl
:/home/xxx # supervisorctl
foo RUNNING pid 17679, uptime 19:21:08
Nginx配置
server {
listen 80;
server_name 服务器IP;
location / {
proxy_pass http://127.0.0.1:9001/RPC2;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
安装WEB界面
Supervisord Multi Server Monitoring Tool
git clone https://github.com/mlazarov/supervisord-monitor.git
cp application/config/supervisor.php.example application/config/supervisor.php
vim application/config/supervisor.php
<?php
// Dashboard columns. 2 or 3
$config['supervisor_cols'] = 2;
// Refresh Dashboard every x seconds. 0 to disable
$config['refresh'] = 10;
// Enable or disable Alarm Sound
$config['enable_alarm'] = true;
// Show hostname after server name
$config['show_host'] = false;
$config['supervisor_servers'] = array(
'服务器HOSTNAME(显示用)' => array(
'url' => 'http://服务器IP地址',
'port' => '80',
'username' => 'admin',
'password' => 'admin'
),
/*
'server02' => array(
'url' => 'http://server02.app/RPC2',
'port' => '9001'
),
'server03' => array(
'url' => 'http://server03.app/RPC2',
'port' => '9001'
),
*/
);
// Set timeout connecting to remote supervisord RPC2 interface
$config['timeout'] = 3;
// Path to Redmine new issue url
$config['redmine_url'] = 'http://redmine.url/path_to_new_issue_url';
// Default Redmine assigne ID
$config['redmine_assigne_id'] = '69';
配置Nginx
server {
listen 80;
server_name super.com;
set $web_root /home/xxx/www/supervisord-monitor-master/public_html;
root $web_root;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~ /*\.php$ {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $web_root$fastcgi_script_name;
fastcgi_param SCHEME $scheme;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
access_log /usr/local/nginx/logs/xxx.log;
error_log /usr/local/nginx/logs/xxx_error.log;
}
访问WEB界面
如果要配置多台Supervisor的监控,只需要对变量进行扩充即可:
$config['supervisor_servers']
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。