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

python測試開發(fā)django之使用supervisord?后臺啟動celery?服務(worker/beat)

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

前言

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

環(huán)境準備

centos 安裝 supervisord

yum install -y supervisord

debian 安裝 supervisord

apt-get install -y supervisor

supervisord.conf

安裝完成后在/etc/supervisor 目錄下會有個配置文件 supervisord.conf

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

cat 查看內容

# 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

在項目中我們需要用到此配置,可以在項目根目錄導出一份

echo_supervisord_conf > ./supervisord.conf

文件內容編寫

supervisord.conf文件內容編寫, 前面內容不用改,直接接著在后面寫
比如我需要后臺啟動celery的worker和beat服務

; 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不支持后臺進程
process_name=%(program_name)s
#user=root                                 ;進程啟動用戶
autostart=true                           ;是否隨supervisor啟動
autorestart=true                         ;是否在掛了之后重啟,意外關閉后會重啟,比如kill掉!
startretries=3                           ;啟動嘗試次數(shù)
stderr_logfile=./celery_worker.log           ;標準輸出文件
stdout_logfile=./celery_worker.log        ;標準輸出文件
loglevel=info                            ;日志的級別


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

啟動服務

啟動服務

supervisord -c /path/supervisord.conf

關閉服務

supervisorctl shutdown

運行過程,啟動沒問題,不顯示任何內容,如果需要關閉用shutdown

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

查看啟動的服務

supervisorctl status

執(zhí)行結果如下

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

說明啟動了celery和celery-beat兩個服務

查看日志

我們在配置里面指定了./celery_worker.log 文件保存運行日志,所以可以直接查看這個文件

tail -f celery_worker.log -n 30

運行就可以看到worker運行的日志了

參考教程 http://www.fzitv.net/article/146238.htm

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

相關文章

  • keras分類之二分類實例(Cat and dog)

    keras分類之二分類實例(Cat and dog)

    這篇文章主要介紹了keras分類之二分類實例(Cat and dog),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • python中pika模塊問題的深入探究

    python中pika模塊問題的深入探究

    這篇文章主要給大家介紹了關于python中pika模塊問題的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用python具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2018-10-10
  • OpenCV搞定騰訊滑塊驗證碼的實現(xiàn)代碼

    OpenCV搞定騰訊滑塊驗證碼的實現(xiàn)代碼

    這篇文章主要介紹了OpenCV搞定騰訊滑塊驗證碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-05-05
  • 基于并發(fā)服務器幾種實現(xiàn)方法(總結)

    基于并發(fā)服務器幾種實現(xiàn)方法(總結)

    下面小編就為大家分享一篇基于并發(fā)服務器幾種實現(xiàn)方法(總結),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2017-12-12
  • python協(xié)程用法實例分析

    python協(xié)程用法實例分析

    這篇文章主要介紹了python協(xié)程用法,實例分析Python中協(xié)議的概念、功能及使用方法,需要的朋友可以參考下
    2015-06-06
  • Python模塊結構與布局操作方法實例分析

    Python模塊結構與布局操作方法實例分析

    這篇文章主要介紹了Python模塊結構與布局操作方法,結合實例形式分析了Python模塊與布局的相關概念、使用方法與相關注意事項,需要的朋友可以參考下
    2017-07-07
  • Python使用unittest進行有效測試的示例詳解

    Python使用unittest進行有效測試的示例詳解

    這篇文章主要介紹了如何使用?unittest?來編寫和運行單元測試,希望通過閱讀本文,大家能了解?unittest?的基本使用方法,以及如何使用?unittest?中的斷言方法和測試用例組織結構
    2023-06-06
  • Python sklearn中的.fit與.predict的用法說明

    Python sklearn中的.fit與.predict的用法說明

    這篇文章主要介紹了Python sklearn中的.fit與.predict的用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-06-06
  • 用python寫一個windows下的定時關機腳本(推薦)

    用python寫一個windows下的定時關機腳本(推薦)

    由于本人經常使用筆記本共享WiFi,但是又不想筆記本開機一夜,每次都是使用dos命令關機,感覺好麻煩,然后小編想到用python寫一個定時關機的腳本,具體實例代碼請參考本文
    2017-03-03
  • numpy創(chuàng)建神經網絡框架

    numpy創(chuàng)建神經網絡框架

    本文介紹了使用numpy從零搭建了一個類似于pytorch的深度學習框架,可以用在很多地方,有需要的朋友可以自行參考一下
    2021-08-08

最新評論

榆中县| 丰台区| 襄垣县| 荥阳市| 临安市| 大安市| 开远市| 宁国市| 若羌县| 西平县| 建平县| 开化县| 西吉县| 黑龙江省| 五家渠市| 喀喇沁旗| 十堰市| 新营市| 隆尧县| 九台市| 万全县| 阿克陶县| 嘉黎县| 宜都市| 利津县| 惠安县| 瑞安市| 紫云| 镇康县| 临泽县| 卢湾区| 望都县| 定州市| 郓城县| 手机| 祥云县| 光山县| 古浪县| 南靖县| 新津县| 雷州市|