婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Linux中的進程守護supervisor安裝配置及使用

Linux中的進程守護supervisor安裝配置及使用

熱門標簽:蕪湖呼叫中心外呼系統哪家強 電銷機器人怎么錄音 漯河電銷外呼系統價格 貴港市機器人外呼系統團隊 ec外呼系統怎么樣 天津外呼系統運營商 咸陽穩定外呼系統公司 貴陽語音電銷機器人 征服者快捷酒店地圖標注

supervisor是一個很好的守護程序管理工具,配置方面自動啟動,日志輸出,自動切割日志等等一系列強大功能,下面是在CentOS下安裝使用supervisor的記錄。

安裝

# epel源
yum install epel-release
# 安裝supervisor
yum install -y supervisor
# 開機自啟動
systemctl enable supervisord
# 啟動supervisord服務
systemctl start supervisord 
Bash

配置路徑

# 主配置文件
/etc/supervisord.conf
# 運行程序配置文件夾
/etc/supervisord.d/
Bash

操作命令

systemctl stop supervisord
systemctl start supervisord
systemctl status supervisord
# 重新加載配置文件,不影響正在運行的程序
systemctl reload supervisord
systemctl restart supervisord
Bash

使用測試

寫一個測試腳本test.php,記錄啟動次數和運行。

<?php
try {
  $a = file_get_contents('./times.json');
} catch (Exception $e) {
  $a = 0;
}
$a ++;
file_put_contents('./times.json', $a);
echo date('Y-m-d H:i:s') . " 這是第{$a}次啟動!!!!" . PHP_EOL;

$i = 1;
while (1) {
  echo date('Y-m-d H:i:s') . " 第{$i}次輸出" . PHP_EOL;
  $i ++;
  sleep(5);
}

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

上面只是一些必要的基本配置,更詳細的配置參考:

;[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

運行重啟或者重載配置命令加載新配置:

systemctl restart supervisord
systemctl reload supervisord
Bash

查看進程:

[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

可以重啟服務器,或者kill -9 PID殺死進程,會發現supervisor會第一時間重啟程序,達到了守護進程的目的。

關于配置方面仔細看看上面的參考,基本上涵蓋了需要的功能,多進程的運行,切割日志的大小,保留數量等等,功能強大而且使用。

更多高級功能請參考supervisor官網使用手冊:傳送門

總結

以上所述是小編給大家介紹的Linux中的進程守護supervisor安裝配置及使用,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

標簽:西藏 東營 怒江 香港 淮北 西寧 攀枝花 濰坊

巨人網絡通訊聲明:本文標題《Linux中的進程守護supervisor安裝配置及使用》,本文關鍵詞  Linux,中的,進程,守護,supervisor,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Linux中的進程守護supervisor安裝配置及使用》相關的同類信息!
  • 本頁收集關于Linux中的進程守護supervisor安裝配置及使用的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 汨罗市| 当涂县| 桑植县| 潮安县| 锦州市| 蒙山县| 建水县| 蒲城县| 会东县| 怀宁县| 广宁县| 龙江县| 玛沁县| 安多县| 彩票| 仁布县| 兴隆县| 房山区| 潜山县| 峡江县| 鹰潭市| 邵武市| 武清区| 通辽市| 宜兰县| 法库县| 揭阳市| 兰州市| 麻江县| 忻州市| 伊川县| 白玉县| 常山县| 岱山县| 马尔康县| 油尖旺区| 台湾省| 平乡县| 九寨沟县| 驻马店市| 西安市|