日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

supervisord安装使用简记

發布時間:2024/7/19 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 supervisord安装使用简记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

What is supervisor

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

引用自supervisor官網,中文意思就是是一個C/S架構的系統,用來監控管理類UNIX系統上進程。

Features

簡單,高效,可擴展,兼容性好(Orz,其實不能在windows上用)

想看更多請去官網

Installing

  • 因為是用Python實現的,所以最簡單的方式是pip install supervisor
  • ubuntu系統上也可以直接使用sudo apt-get install supervisor
  • Configure

    • 使用 echo_supervisord_conf 就可以看到默認的配置文件,如下:
    ? Log echo_supervisord_conf ; Sample supervisor config file. ; ; For more information on the config file, please see: ; http://supervisord.org/configuration.html ; ; Notes: ; - Shell expansion ("~" or "$HOME") is not supported. Environment ; variables can be expanded using this syntax: "%(ENV_HOME)s". ; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
    • 配置文件

    使用echo_supervisord_conf > /etc/supervisord.conf命令將配置文件保存在xx下面,然后修改配置文件。推薦的方式是將最后一行修改到某個固定文件夾,如下:

    [include] files = /etc/supervisord.d/*.ini

    這樣每次運行都會加載此目錄下的配置文件,每個文件單獨管理一個進程。而*.ini的內容一般如下:

    配置1
    [program:simpleserver] command=python -m SimpleHTTPServer # 執行的命令 ,若是虛擬環境則需要注意命令的路徑,見配置2 directory=/home/wang/Downloads # 執行命令的路徑 user=wang # 執行命令的用戶 autorestart=true # 出錯后自動重啟 redirect_stderr=true # 錯誤日志重定向 stdout_logfile=/home/wang/Log/SimpleHTTPServer.log # 日志的路徑 loglevel=info # 日志的級別
    配置2
    [program:hongbaoyun] command=/home/wang/.virtualenvs/xxx-virtual-env/bin/python manage.py runserver 0.0.0.0:9999 # 此處python位置是virtualenv中python的位置 directory=/home/wang/Workspace/khb/hongbaoyun user=wang

    Run

    • 啟動
      supervisord -c supervisord.conf # 指定配置文件啟動supervisord

    • 啟動spuervisordctl
      supervisordctl

    • supervisordctl常用命令

    supervisorctl stop program_name # 停止某一個進程,program_name 為 [program:x] 里的 xsupervisorctl start program_name # 啟動某個進程supervisorctl restart program_name # 重啟某個進程supervisorctl stop groupworker: # 結束所有屬于名為 groupworker 這個分組的進程 (start,restart 同理)supervisorctl stop groupworker:name1 # 結束 groupworker:name1 這個進程 (start,restart 同理)supervisorctl stop all # 停止全部進程,注:start、restartUnlinking stale socket /tmp/supervisor.sock 、stop 都不會載入最新的配置文件supervisorctl reload # 載入最新的配置文件,停止原有進程并按新的配置啟動、管理所有進程supervisorctl update # 根據最新的配置文件,啟動新配置或有改動的進程,配置沒有改動的進程不會受影響而重啟
    • 圖行管理界面

    在配置文件中去掉 [inet http server]的注釋就可在瀏覽器中通過127.0.0.1:8000中看到圖形管理界面

    FAQ

    • 可能會出現 Unlinking stale socket /tmp/supervisor.sock 的錯誤,解決方式見 http://stackoverflow.com/questions/14479894/stopping-supervisord-shut-down, 是配置文件的問題

    • 開機自動啟動,見 http://serverfault.com/questions/96499/how-to-automatically-start-supervisord-on-linux-ubuntu

    Refer

    • http://www.restran.net/2015/10/04/supervisord-tutorial/ (很詳細,推薦看)

    • http://supervisord.org/ (官網)

    • http://stackoverflow.com/questions/14479894/stopping-supervisord-shut-down

    • http://serverfault.com/questions/96499/how-to-automatically-start-supervisord-on-linux-ubuntu

    轉載于:https://www.cnblogs.com/wswang/p/5795766.html

    總結

    以上是生活随笔為你收集整理的supervisord安装使用简记的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。