欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python測(cè)試開發(fā)django之使用supervisord?后臺(tái)啟動(dòng)celery?服務(wù)(worker/beat)

 更新時(shí)間:2022年07月19日 16:41:12   作者:上海-悠悠  
Supervisor是用Python開發(fā)的一個(gè)client/server服務(wù),是Linux/Unix系統(tǒng)下的一個(gè)進(jìn)程管理工具,不支持Windows系統(tǒng),這篇文章主要介紹了python測(cè)試開發(fā)django之使用supervisord?后臺(tái)啟動(dòng)celery?服務(wù)(worker/beat),需要的朋友可以參考下

前言

Supervisor(‘http://supervisord.org/’)是用Python開發(fā)的一個(gè)client/server服務(wù),是Linux/Unix系統(tǒng)下的一個(gè)進(jìn)程管理工具,不支持Windows系統(tǒng)。
它可以很方便的監(jiān)聽、啟動(dòng)、停止、重啟一個(gè)或多個(gè)進(jìn)程。
用Supervisor管理的進(jìn)程,當(dāng)一個(gè)進(jìn)程意外被殺死,supervisort監(jiān)聽到進(jìn)程死后,會(huì)自動(dòng)將它重新拉起,很方便的做到進(jìn)程自動(dòng)恢復(fù)的功能,不再需要自己寫shell腳本來控制。

環(huán)境準(zhǔn)備

centos 安裝 supervisord

yum install -y supervisord

debian 安裝 supervisord

apt-get install -y supervisor

supervisord.conf

安裝完成后在/etc/supervisor 目錄下會(huì)有個(gè)配置文件 supervisord.conf

# cd /etc/supervisor
/etc/supervisor# ls
conf.d	supervisord.conf

cat 查看內(nèi)容

# cat supervisord.conf 
; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; 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:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; 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/conf.d/*.conf

在項(xiàng)目中我們需要用到此配置,可以在項(xiàng)目根目錄導(dǎo)出一份

echo_supervisord_conf > ./supervisord.conf

文件內(nèi)容編寫

supervisord.conf文件內(nèi)容編寫, 前面內(nèi)容不用改,直接接著在后面寫
比如我需要后臺(tái)啟動(dòng)celery的worker和beat服務(wù)

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html

; 前面文檔省略,不用刪,接著后面寫

[program:celery-worker]
command=celery -A hrun2_web worker -l info ; 管理命令,supervisor不支持后臺(tái)進(jìn)程
process_name=%(program_name)s
#user=root                                 ;進(jìn)程啟動(dòng)用戶
autostart=true                           ;是否隨supervisor啟動(dòng)
autorestart=true                         ;是否在掛了之后重啟,意外關(guān)閉后會(huì)重啟,比如kill掉!
startretries=3                           ;啟動(dòng)嘗試次數(shù)
stderr_logfile=./celery_worker.log           ;標(biāo)準(zhǔn)輸出文件
stdout_logfile=./celery_worker.log        ;標(biāo)準(zhǔn)輸出文件
loglevel=info                            ;日志的級(jí)別


[program:celery-beat]
command=celery -A hrun2_web beat ; 管理命令,supervisor不支持后臺(tái)進(jìn)程
process_name=%(program_name)s
#user=root                                 ;進(jìn)程啟動(dòng)用戶
autostart=true                           ;是否隨supervisor啟動(dòng)
autorestart=true                         ;是否在掛了之后重啟,意外關(guān)閉后會(huì)重啟,比如kill掉!
startretries=3                           ;啟動(dòng)嘗試次數(shù)
stderr_logfile=./celery_beat.log          ;標(biāo)準(zhǔn)輸出文件
stdout_logfile=./celery_beat.log        ;標(biāo)準(zhǔn)輸出文件
loglevel=info                            ;日志的級(jí)別

啟動(dòng)服務(wù)

啟動(dòng)服務(wù)

supervisord -c /path/supervisord.conf

關(guān)閉服務(wù)

supervisorctl shutdown

運(yùn)行過程,啟動(dòng)沒問題,不顯示任何內(nèi)容,如果需要關(guān)閉用shutdown

root@13107c465557:/code# supervisord -c ./supervisord.conf
root@13107c465557:/code# supervisorctl shutdown
Shut down

查看啟動(dòng)的服務(wù)

supervisorctl status

執(zhí)行結(jié)果如下

root@13107c465557:/code# supervisorctl status
celery-worker RUNNING pid 234, uptime 0:00:14
celery-beat RUNNING pid 235, uptime 0:00:14

說明啟動(dòng)了celery和celery-beat兩個(gè)服務(wù)

查看日志

我們?cè)谂渲美锩嬷付?code>./celery_worker.log 文件保存運(yùn)行日志,所以可以直接查看這個(gè)文件

tail -f celery_worker.log -n 30

運(yùn)行就可以看到worker運(yùn)行的日志了

參考教程 http://www.dbjr.com.cn/article/146238.htm

到此這篇關(guān)于python測(cè)試開發(fā)django之使用supervisord后臺(tái)啟動(dòng)celery服務(wù)(worker/beat)的文章就介紹到這了,更多相關(guān)supervisord后臺(tái)啟動(dòng)celery服務(wù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 利用Python抓取行政區(qū)劃碼的方法

    利用Python抓取行政區(qū)劃碼的方法

    做項(xiàng)目的時(shí)候會(huì)需要用到各個(gè)行政區(qū)劃的代碼,最近就碰巧遇到有這個(gè)需求,于是就上網(wǎng)搜了一下,測(cè)試后分享給大家,這篇文章就給大家分享了利用Python抓取行政區(qū)劃碼的示例代碼,有需要的朋友們可以參考借鑒,下面跟著小編一起去學(xué)習(xí)學(xué)習(xí)吧。
    2016-11-11
  • 用Python下載一個(gè)網(wǎng)頁保存為本地的HTML文件實(shí)例

    用Python下載一個(gè)網(wǎng)頁保存為本地的HTML文件實(shí)例

    今天小編就為大家分享一篇用Python下載一個(gè)網(wǎng)頁保存為本地的HTML文件實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • Python安裝Numpy和matplotlib的方法(推薦)

    Python安裝Numpy和matplotlib的方法(推薦)

    下面小編就為大家?guī)硪黄狿ython安裝Numpy和matplotlib的方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • Python使用Pillow進(jìn)行圖像處理

    Python使用Pillow進(jìn)行圖像處理

    這篇文章介紹了Python使用Pillow進(jìn)行圖像處理的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-06-06
  • python獲取柵格點(diǎn)和面值的實(shí)現(xiàn)

    python獲取柵格點(diǎn)和面值的實(shí)現(xiàn)

    這篇文章主要介紹了python獲取柵格點(diǎn)和面值的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有多幫助。一起跟隨小編過來看看吧
    2020-03-03
  • python 成功引入包但無法正常調(diào)用的解決

    python 成功引入包但無法正常調(diào)用的解決

    這篇文章主要介紹了python 成功引入包但無法正常調(diào)用的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • python實(shí)現(xiàn)五子棋算法

    python實(shí)現(xiàn)五子棋算法

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)五子棋算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Python列表reverse()函數(shù)使用方法詳解

    Python列表reverse()函數(shù)使用方法詳解

    這篇文章主要詳細(xì)介紹了Python列表reverse()函數(shù)使用方法,文章通過代碼示例講解的非常詳細(xì),對(duì)我們的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2023-07-07
  • Django連接數(shù)據(jù)庫并實(shí)現(xiàn)讀寫分離過程解析

    Django連接數(shù)據(jù)庫并實(shí)現(xiàn)讀寫分離過程解析

    這篇文章主要介紹了Django連接數(shù)據(jù)庫并實(shí)現(xiàn)讀寫分離過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-11-11
  • Python標(biāo)準(zhǔn)庫uuid模塊(生成唯一標(biāo)識(shí))詳解

    Python標(biāo)準(zhǔn)庫uuid模塊(生成唯一標(biāo)識(shí))詳解

    uuid通過Python標(biāo)準(zhǔn)庫的uuid模塊生成通用唯一ID(或“UUID”)的一種快速簡(jiǎn)便的方法,下面這篇文章主要給大家介紹了關(guān)于Python標(biāo)準(zhǔn)庫uuid模塊(生成唯一標(biāo)識(shí))?的相關(guān)資料,需要的朋友可以參考下
    2022-05-05

最新評(píng)論