新聞中心
supervisor是一個(gè)很好的守護(hù)程序管理工具,配置方面自動(dòng)啟動(dòng),日志輸出,自動(dòng)切割日志等等一系列強(qiáng)大功能,下面是在CentOS下安裝使用supervisor的記錄。

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比鹽湖網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式鹽湖網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋鹽湖地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。
安裝
# epel源 yum install epel-release # 安裝supervisor yum install -y supervisor # 開機(jī)自啟動(dòng) systemctl enable supervisord # 啟動(dòng)supervisord服務(wù) systemctl start supervisord Bash
配置路徑
# 主配置文件 /etc/supervisord.conf # 運(yùn)行程序配置文件夾 /etc/supervisord.d/ Bash
操作命令
systemctl stop supervisord systemctl start supervisord systemctl status supervisord # 重新加載配置文件,不影響正在運(yùn)行的程序 systemctl reload supervisord systemctl restart supervisord Bash
使用測試
寫一個(gè)測試腳本test.php,記錄啟動(dòng)次數(shù)和運(yùn)行。
PHP
在程序配置文件夾
/etc/supervisord.d中添加test.ini:[program:test] directory=/home/wwwroot/test.cc command=php test.php autostart=true autorestart=true stderr_logfile=/home/wwwroot/test.cc/log/error.log stdout_logfile=/home/wwwroot/test.cc/log/out.log Ini上面只是一些必要的基本配置,更詳細(xì)的配置參考:
;[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=true ; retstart at unexpected quit (default: true) ;startsecs=10 ; 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) ;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) Ini運(yùn)行重啟或者重載配置命令加載新配置:
systemctl restart supervisord systemctl reload supervisord Bash查看進(jìn)程:
[root@localhost test.cc]# ps -aux | grep test.php root 22277 0.0 0.6 269732 12124 ? S 17:38 0:00 php test.php root 22335 0.0 0.0 112712 996 pts/0 S+ 17:41 0:00 grep --color=auto test.php Bash可以重啟服務(wù)器,或者
kill -9 PID殺死進(jìn)程,會(huì)發(fā)現(xiàn)supervisor會(huì)第一時(shí)間重啟程序,達(dá)到了守護(hù)進(jìn)程的目的。關(guān)于配置方面仔細(xì)看看上面的參考,基本上涵蓋了需要的功能,多進(jìn)程的運(yùn)行,切割日志的大小,保留數(shù)量等等,功能強(qiáng)大而且使用。
更多高級(jí)功能請(qǐng)參考
supervisor官網(wǎng)使用手冊(cè):傳送門總結(jié)
以上所述是小編給大家介紹的linux中的進(jìn)程守護(hù)supervisor安裝配置及使用,大家如有疑問可以留言,或者聯(lián)系站長。感謝親們支持?。?!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!成都創(chuàng)新互聯(lián)建站主營:成都網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、網(wǎng)站改版的網(wǎng)站建設(shè)公司,提供成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、成都網(wǎng)站推廣、成都網(wǎng)站優(yōu)化seo、響應(yīng)式移動(dòng)網(wǎng)站開發(fā)制作等網(wǎng)站服務(wù)。
標(biāo)題名稱:Linux中的進(jìn)程守護(hù)supervisor安裝配置及使用
分享地址:http://www.5511xx.com/article/cciehod.html


咨詢
建站咨詢
