天天看點

centos supervisor 安裝及常見的問題

supervisor安裝

方法一、使用yum指令安裝(推薦)

$ sudo su - #切換為root使用者

# yum install epel-release

# yum install -y supervisor

# systemctl enable supervisord 

systemctl enable supervisord.service

# 開機自啟動

systemctl start supervisord 

systemctl start supervisord.service

# 檢視啟動supervisord服務

# systemctl status supervisord

 ps -aux|grep supervisord

 # 檢視supervisord服務狀态

# ps -ef|grep supervisord # 檢視是否存在supervisord程序

方法一、源碼安裝(省事的不推薦)

https://pypi.org/project/supervisor/#files

supervisor 修改加載配置路徑

vi /etc/supervisord.conf 

[include]

files = /data/supervisord.d/*.conf

/etc/supervisord.d/*.conf

spawn 在expect裡面

安裝expect:

yum -y install expect

centos檢視防火牆:

檢視防火牆狀态

firewall-cmd --state

停止firewall

systemctl stop firewalld.service

開啟firewall

systemctl start firewalld

禁止firewall開機啟動

systemctl disable firewalld.service 

開機啟動防火牆

systemctl enable firewalld

supervisor 程序配置cesi 檔案例子 

[program:cesi] #程式名字不能重複

directory =/root/cesi

command=/root/cesi/venv/bin/python3 ./cesi/run.py --config-file /etc/cesi.conf 

autostart=true

autorestart=true

startsecs=3

user=root

numprocs=1

redirect_stderr=true

stdout_logfile_backups = 7 

stdout_logfile_maxbytes = 50MB  

stdout_logfile=/root/cesi/cesi_stdout.log

supervisor程序 web 管理界面cesi

---第一種安裝---

參考官方REAME.md

https://github.com/gamegos/cesi

使用yarn install安裝的時候,提示錯誤

yarn config set ignore-engines true

---第二種安裝---

pip install flask

腳本安裝配置cesi

vi /home/cesi.sh

cesi配置檔案例子

vi /etc/cesi.conf

# This is the CeSI's own configuration.

[cesi]

# Database Uri

database = "sqlite:///users.db"                         # Relative path

# Etc

#database = "sqlite:opt/cesi/< version >/users.db"  # Absolute path

#database = "postgres://<user>:<password>@localhost:5432/<database_name>"

#database = "mysql+pymysql://<user>:<password>@localhost:3306/<database_name>"

activity_log = "activity.log"   # File path for CeSI logs

admin_username = "admin"        # Username of admin user

admin_password = "admin"        # Password of admin user

# This is the definition section for new supervisord node.

# [[nodes]]

# name = "api"          # (String) Unique name for supervisord node.

# environment = ""      # (String) The environment name provides logical grouping of supervisord nodes. It can be used as filtering option in the UI.

# username = ""         # (String) Username of the XML-RPC interface of supervisord Set nothing if no username is configured

# password = ""         # (String) Password of the XML-RPC interface of supervisord. Set nothing if no username is configured

# host = "127.0.0.1"    # (String) Host of the XML-RPC interface of supervisord

# port = "9001"         # (String) Port of the XML-RPC interface of supervisord

# Default supervisord nodes

[[nodes]]

name = "ecs-soms"

environment = "soms"

username = "admin"  #supervisord web 的使用者名

password = "admin" #密碼

host = "127.0.0.1"

port = "9001"

常用指令:

supervisord --nodaemon 前台啟動Supervisor服務

supervisorctl -i 進入互動式Shell

supervisorctl status 檢視任務清單

supervisorctl status helloworld 檢視指定任務的狀态

supervisorctl stop/start/restart all 結束/啟動/重新開機所有任務

supervisorctl stop/start/restart helloworld 結束/啟動/重新開機指定任務

supervisorctl reroad 重新加載配置檔案,不增減任務

supervisorctl update all 重新加載配置檔案,并進行必要的增減任務

supervisorctl remove/add 移除/添加任務(配置檔案中已經存在的任務)

supervisorctl tail -f helloworld 實時檢視任務的控制台輸出

supervisorctl tail -f helloworld stderr 實時檢視任務的控制台錯誤輸出

supervisorctl reload 重新開機Supervisor服務

supervisorctl fg helloworld 将任務拉到前台,此時Ctrl+C不會結束任務,而是将任務放回背景

supervisorctl shutdown 終止Supervisor服務

supervisorctl clear all 清楚所有程序的日志檔案

supervisorctl maintail -f 實時檢視Supervisor服務的日志檔案

supervisorctl signal SIGTERM all 結束所有程序

supervisorctl signal SIGKILL all 殺死所有程序

supervisorctl --serverurl http://localhost:9001 status 管理遠端Supervisor服務

在運作時遇到的問題及解決:

http://mtjo.net/portal/article/index/id/21/cid/4.html?page=3

https://www.oschina.net/question/729460_141976

https://blog.csdn.net/weixin_44777680/article/details/105607945