最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2019年07月10日 09:08:02   作者:行星帶  
supervisor是一個很好的守護程序管理工具,配置方面自動啟動,日志輸出,自動切割日志等等一系列強大功能,下面是在CentOS下安裝使用supervisor的記錄,非常不錯,感興趣的朋友跟隨小編一起看看吧

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

安裝

# epel源
yum install epel-release
# 安裝supervisor
yum install -y supervisor
# 開機自啟動
systemctl enable supervisord
# 啟動supervisord服務(wù)
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,記錄啟動次數(shù)和運行。

<?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

可以重啟服務(wù)器,或者kill -9 PID殺死進程,會發(fā)現(xiàn)supervisor會第一時間重啟程序,達到了守護進程的目的。

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

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

總結(jié)

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

相關(guān)文章

  • CentOS搭建PHP服務(wù)器環(huán)境簡明教程

    CentOS搭建PHP服務(wù)器環(huán)境簡明教程

    這篇文章主要介紹了CentOS搭建PHP服務(wù)器環(huán)境的方法,簡單講述了CentOS平臺安裝Apache、mysql、php環(huán)境及相關(guān)測試代碼,非常簡單實用,需要的朋友可以參考下
    2018-03-03
  • Linux命令之文件分割split命令方式

    Linux命令之文件分割split命令方式

    這篇文章主要介紹了Linux命令之文件分割split命令方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用

    Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用

    這篇文章主要介紹了Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • Linux下正確快速刪除海量文件的方法分享

    Linux下正確快速刪除海量文件的方法分享

    linux服務(wù)器運行久了,可能會出現(xiàn)海量的垃圾文件去刪除,下面這篇文章就給大家分享了在Linux下正確快速刪除海量文件的方法,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-02-02
  • 在Linux中備份mysql數(shù)據(jù)庫和表的詳細操作

    在Linux中備份mysql數(shù)據(jù)庫和表的詳細操作

    備份數(shù)據(jù)庫和備份表是兩種不同的東西,備份數(shù)據(jù)庫是原來的庫是什么樣,新庫就是什么樣,里面含有復制了表,唯一區(qū)別就是庫名不一樣,備份表是把原表一模一樣復制一遍備份,本文給大家介紹了在Linux中備份msyql數(shù)據(jù)庫和表的詳細操作,需要的朋友可以參考下
    2024-11-11
  • C語言中 malloc,calloc,realloc的區(qū)別

    C語言中 malloc,calloc,realloc的區(qū)別

    這篇文章主要介紹了C語言中 malloc、calloc、realloc的區(qū)別的相關(guān)資料,需要的朋友可以參考下
    2017-02-02
  • linux ubuntu中安裝、卸載和刪除python-igraph的方法教程

    linux ubuntu中安裝、卸載和刪除python-igraph的方法教程

    igraph是一個進行圖計算和社交網(wǎng)絡(luò)分析的軟件包,支持python語言。下面這篇文章主要給大家介紹了關(guān)于在linux ubuntu中安裝、卸載和刪除python-igraph的方法教程,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下。
    2017-11-11
  • CentOS7增加或修改SSH端口號的方法

    CentOS7增加或修改SSH端口號的方法

    這篇文章主要介紹了CentOS7增加或修改SSH端口號的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-07-07
  • 詳解Linux下Nginx+Tomcat整合的安裝與配置

    詳解Linux下Nginx+Tomcat整合的安裝與配置

    本篇文章主要介紹了Linux下Nginx+Tomcat整合的安裝與配置,具有一定的參考價值,有興趣的可以了解一下。
    2017-01-01
  • Linux之UDP協(xié)議及其編程全流程

    Linux之UDP協(xié)議及其編程全流程

    這篇文章主要介紹了Linux之UDP協(xié)議及其編程全流程,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03

最新評論

宁国市| 保定市| 闽侯县| 佳木斯市| 临城县| 陆良县| 武定县| 上栗县| 安陆市| 霍林郭勒市| 旺苍县| 龙山县| 同江市| 尼木县| 五家渠市| 岢岚县| 偏关县| 县级市| 毕节市| 桦川县| 元江| 志丹县| 礼泉县| 上饶市| 子洲县| 河北省| 吴堡县| 高邮市| 刚察县| 田林县| 罗江县| 全南县| 北安市| 清远市| 普安县| 青岛市| 梨树县| 台湾省| 芷江| 新竹县| 汉源县|