CentOS6.5下supervisor 3.0安裝與使用
1、檢視python版本
[[email protected] ~]# python -V
Python 2.6.62、下載並安裝supervisor
wget http://pypi.python.org/packages/source/s/supervisor/supervisor-3.0b1.tar.gz --no-check-certificate
tar -zxvf supervisor-3.0b1.tar.gz
cd supervisor-3.0b1
python setup.py install
最後顯示:
Using /usr/lib/python2.6/site-packages
Finished processing dependencies for supervisor==3.0b1
表示成功
[
yum install python-setuptools
安裝setuptools後也可以easy_install supervisor
]
3、 設定supervisor配置檔案
touch /var/log/supervisord.log
chmod 777 /var/log/supervisord.log
建立預設的配置檔案
echo_supervisord_conf >/etc/supervisord.conf
chown www:www /etc/supervisord.conf
chmod 744 /etc/supervisord.conf
修改配置檔案
vi /etc/supervisord.conf
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Note: shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; socket file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
;port=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface)
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;umask=022 ; (process file creation umask;default 022)
;user=chrism ; (default is current user, required if root)
;identifier=supervisor ; (supervisord identifier, default is 'supervisor')
;directory=/tmp ; (default is not to cd during start)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
;childlogdir=/var/log/ ; ('AUTO' child log dir, default $TEMP)
;environment=KEY=value ; (key value pairs to add to environment)
;strip_ansi=false ; (strip ansi escape codes in logs; def. false)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available
; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.
;[program:theprogramname]
;command=/bin/cat ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=999 ; the relative start priority (default 999)
;autostart=true ; start at supervisord start (default: true)
;autorestart=unexpected ; whether/when to restart (default: unexpected)
;startsecs=1 ; number of secs prog must stay running (def. 1)
;startretries=3 ; max # of serial start failures (default 3)
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A=1,B=2 ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils)
; The below sample eventlistener section shows all possible
; eventlistener subsection values, create one or more 'real'
; eventlistener: sections to be able to handle event notifications
; sent by supervisor.
;[eventlistener:theeventlistenername]
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;events=EVENT ; event notif. types to subscribe to (req'd)
;buffer_size=10 ; event buffer queue size (default 10)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=-1 ; the relative start priority (default -1)
;autostart=true ; start at supervisord start (default: true)
;autorestart=unexpected ; whether/when to restart (default: unexpected)
;startsecs=1 ; number of secs prog must stay running (def. 1)
;startretries=3 ; max # of serial start failures (default 3)
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups ; # of stderr logfile backups (default 10)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A=1,B=2 ; process environment additions
;serverurl=AUTO ; override serverurl computation (childutils)
; The below sample group section shows all possible group values,
; create one or more 'real' group: sections to create "heterogeneous"
; process groups.
;[group:thegroupname]
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
;priority=999 ; the relative start priority (default 999)
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/*.ini
--------------------------------------------------------------------
增加自定義的後臺程序(注意程序名之間用一個:分隔)
mkdir /etc/supervisor/
chown www:www -R /etc/supervisor/
---------------------
例子1:
[program:server]
command=python /opt/archive_server/server.py
autorstart=true
redirect_stderr=true
stdout_logfile=/mnt/log/supervisord_server.log
directory=/tmp
user=root
priority=1
---------------------------------------
4、啟動指令碼(高大上些)
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PROGNAME=supervisord
DAEMON=/usr/bin/$PROGNAME
CONFIG=/etc/$PROGNAME.conf
PIDFILE=/tmp/$PROGNAME.pid
DESC="supervisord daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
start()
{
echo -n "Starting $DESC: $PROGNAME"
$DAEMON -c $CONFIG
echo "..."
}
stop()
{
echo -n "Stopping $DESC: $PROGNAME"
supervisor_pid=$(cat $PIDFILE)
kill -15 $supervisor_pid
echo "..."
}
status()
{
ps -ef|grep supervisord
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
-----------------------------------------------
-------------------------------------------------------
/etc/init.d/supervisord start
/etc/init.d/supervisord stop
/etc/init.d/supervisord restart
[[email protected] supervisor-3.0b1]$ ps -ef|grep supervisord
www 30335 1 0 17:23 ? 00:00:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
www 31986 27782 0 17:24 pts/1 00:00:00 grep supervisord
---------------------------------------------
5、開機啟動
vi /etc/rc.d/rc.local
su www -c "/etc/init.d/supervisord start"
su www -c "/usr/bin/supervisorctl start all"
--------------------------------------
例子2:
在 /etc/supervisor/ 目錄下建立 redis.ini 檔案
[program:redis]
command=/usr/bin/redis-server /usr/local/redis/redis.conf
autorstart=true
autorestart=true
stdout_logfile=/tmp/supervisor.log
參考:
http://www.ttlsa.com/linux/using-supervisor-control-program/
https://segmentfault.com/a/1190000003040086
http://www.myexception.cn/operating-system/2016813.html
http://www.linuxidc.com/Linux/2012-11/73832.htm
http://supervisord.org/index.html
相關推薦
CentOS6.5下supervisor 3.0安裝與使用
1、檢視python版本 [[email protected] ~]# python -V Python 2.6.6 2、下載並安裝supervisor wget http://pypi.python.org/packages/source/s/superviso
CentOS6.5下kafka+ZooKeeper下載與安裝詳細教程-單機版
(注:在大資料分析系統中,不會安裝單機版,所以可以直接去看多機版教程,多機版教程也是完整的。) 下載zookeeper: 安裝zookeeper: 將zookeeper-3.4.6.tar.gz拿U盤複製到/home/hadoop目錄下 cd /home/hadoo
Centos6.6下Postgresql9.6.6安裝與配置
postgresql一、環境介紹系統平臺:CentOS release 6.6 (Final)Postgresql:postgresql-9.6.6SELINUX=disabledIptables關閉二、安裝過程1.安裝依賴包yum -y install gcc* yum -y install readlin
CentOS6.5下使用lnmp架構安裝nextcloud雲盤
pass -h style 訪問 param 配置nginx script etag turn 最近兩年隨著各大網盤紛紛關閉,百度雲也早早的就開始限速,文件的安全也沒有保障。所以還不如自己搭建一個網盤。網上看了下,發現有一個nextcloud比較好用。支持多平臺客戶端,支持
CentOS6 5下Nginx1 7 4安裝記錄
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
macOS下MySQL 8.0 安裝與配置教程
原文: macOS下MySQL 8.0 安裝與配置教程 一、前言 1、本教程主要內容 適用Homebrew安裝MySQL MySQL 8.0 基礎適用於配置 MySQL shell管理常用語法示例(使用者、許可權等) MySQL字元編碼配置 MySQL遠端訪問配置 2、本教程
Centos6.5 LAMP環境原始碼包安裝與配置,附安裝包百度網盤地址
Centos6.5 LAMP環境原始碼包安裝與配置 http://pan.baidu.com/s/1nvNruzv 安裝包百度網盤地址 LAMP是一種web網路應用和開發環境,是linux,Apache,MySQL,php/perl的縮寫,每一個
最簡單的redis教程:centos6.5下redis單機版安裝《一》
安裝 命令如下: wget http://download.redis.io/releases/redis-3.0.0.tar.gz tar -zxvf redis-3.0.0.tar.gz cd
centos6.5下vsftpd服務的安裝及配置並通過pam認證實現虛擬使用者檔案共享
FTP的全稱是File Transfer Protocol(檔案傳輸協議),就是專門用來傳輸檔案的協議.它工作在OSI模型的第七層,即是應用層,使用TCP傳輸而不是UDP.這樣FTP客戶端和伺服器建立連線前就要經過一個"三次握手"的過程.FTP服務還有一個非常重要的特點是
centos6.5下LNMP配置(編譯安裝,指定目錄)
一:nginx安裝 1:線檢視系統版本: [[email protected] lib64]# lsb_release -a LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0
centOS6.5下的xampp的mysql與phpmyadmin遠端登陸配置
//////////////////////////2016/05/24///////////////////////////// //////////////////////////by xbw/////////////////////////////////// ///
Centos6.5下安裝cacti-0.8.7i
cacti安裝(初學者)(因為我是新手,在安裝時有很多大大小小的問題,我都在這裏備註上了,歡迎萌新們參考)Cacti功能Cacti是通過 snmpget來獲取數據,使用 RRDtool繪畫圖形,而且你完全可以不需要了解RRDtool復雜的參數。它提供了非常強大的數據和用戶管理功能,可以指定每一個用戶能查看樹狀
CentOS6.5 下Nginx 的安裝與配置
ffffff style 指定 this load() 應用 case 編譯 $? 昨天買了個服務器最近在配置一些基礎環境,想在訪問www.wzpbk.com:8080 不想要後面的:8080就能直接訪問到,聽說了Nginx就研究下給服務器裝上傳說中大名鼎鼎 Ng
Windows下python 3.0版本django的安裝、配置、與啟動
減少 操作 註意 class lin img 裏的 bubuko code 使用的環境是Windows操作系統,python的環境是3.6,django是官網上最新的版本1.10.6,本文介紹從安裝python之後怎樣用過pip管理工具安裝django,以及django的項
redis---在CentOS6.5下安裝與配置
eas 相關 var 可選 tro rip 持久 exec TP 本文詳細介紹redis單機單實例安裝與配置,服務及開機自啟動。如有不對的地方,歡迎大家拍磚o(∩_∩)o (以下配置基於CentOS release 6.5 Final, redis版本3.0.2 [redi
CentOS6.5下安裝Hadoop-2.7.3(圖解教程)
17. node 內容 apr ddbd 忽略 passwd frame shuffle 註:圖片如果損壞,點擊文章鏈接:https://www.toutiao.com/i6627365258090512909/ 安裝好虛擬機(3個節點) YUM源已安裝好、系統版本Ce
centos6.5下redis的安裝與配置心得
$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz $ tar xzf redis-3.2.9.tar.gz $ cd redis-3.2.9 $ make 或者 make install PREFIX=安裝目錄上述流程依次代表,下載r
CentOS6.5下Redis安裝與配置
本文詳細介紹redis單機單例項安裝與配置,服務及開機自啟動。如有不對的地方,歡迎大家拍磚o(∩_∩)o (以下配置基於CentOS release 6.5 Final, redis版本3.0.2 [redis版本號中間位是偶數的是穩定版,奇數的為非穩定版]) 一.安
centos6.5下redis的安裝與配置
$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz $ tar xzf redis-3.2.9.tar.gz $ cd redis-3.2.9 $ make 或者 make install PREFIX=
CentOS6.5下redis3.0.7安裝、啟動、關閉、配置密碼、開機啟動詳細步驟
安裝環境: CentOS 6.5 Redis 3.0.7 下載安裝: 下載檔案到 /usr/local 目錄下 解壓檔案 tar zxvf redis-3.0.7.tar.gz 切換目錄到 redis-3.0.7 目錄下 cd redis-3