摘要:創(chuàng)建文件,加入的進(jìn)程管理中,實(shí)現(xiàn)服務(wù)器后臺(tái)運(yùn)行是在中的進(jìn)程名,隨便取啥上述代碼為使用運(yùn)行。
suopervisor 一、安裝supervisor安裝
注:以下所有操作在CentOS7中進(jìn)行1.安裝CentOS7擴(kuò)展軟件倉(cāng)庫(kù)
sudo yum install -y epel-release2.安裝supervisor
yum install -y supervisor3.查看安裝路徑
rpm -ql supervisor4.修改并定義ini文件 step1:
[program:exmaple] # example是在supercisor中的進(jìn)程名,隨便取啥 command=/usr/local/bin/gunicorn -w 4 -b 127.0.0.1:91 run:app # 上述代碼為使用gunicorn 運(yùn)行flask。run是你的文件名 :app指的是app = Flask(__name__)此處的app 或者是 command=/usr/local/bin/python3 /root/test/test.py # command=運(yùn)行指令所在路徑 需要運(yùn)行的文件(ps:建議使用絕對(duì)路徑) directory=/root/test/ # 需要運(yùn)行的文件所在的絕對(duì)路徑 autostart=true autorestart=true priority=5 killasgroup=true stopasgroup=true
其實(shí)若只是運(yùn)行單個(gè)文件,可以直接使用nohup python test.py & (ps:需cd到test所在文件夾執(zhí)行此命令) 即會(huì)實(shí)現(xiàn)服務(wù)器后臺(tái)運(yùn)行,同時(shí)會(huì)在test.py所在文件夾下生成nohup.out日志文件
[program:myProgram] command=python /home/myname/test.py autostart=true autorestart=ture stdout_logfile=/home/myname/test.log
[program:myProgram] command=/usr/local/bin/gunicorn -w 4 -b 127.0.0.1:91 flask:app directory=/root/example/ autostart=true autorestart=true priority=5 killasgroup=true stopasgroup=true二、啟動(dòng)supervisor
supervisord1.啟動(dòng)Supervisor服務(wù)
supervisorctl start all # 開(kāi)啟所有 supervisorctl status # 查看Supervisor 服務(wù)狀態(tài)2.修改了Supervisor ini文件或者conf文件配置后,需要更新服務(wù)
supervisorctl update # 更新supervisor的配置 supervisorctl reload # 重新加載項(xiàng)目到內(nèi)存中3.重啟supervisor服務(wù)
supervisorctl restart # 不管當(dāng)前是已經(jīng)關(guān)閉還是正在運(yùn)行4.日志路徑
tail -f /var/log/supervisor/supervisord.log5.關(guān)閉supervisor的服務(wù)
supervisorctl stop all # 關(guān)閉所有 supervisorctl stop example # 關(guān)掉其中一個(gè)三、關(guān)于報(bào)錯(cuò)
基本上所有的報(bào)錯(cuò)我都有過(guò), 但是找來(lái)找去還是歸類為一下三種:
沒(méi)有啟動(dòng)supervisord -----> 運(yùn)行supervisord命令
你的配置文件內(nèi)容出錯(cuò)了 ------> 檢查你的配置文件內(nèi)容
你的需要運(yùn)行的代碼出錯(cuò)了 -----> 檢查你的代碼:
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/45238.html
摘要:項(xiàng)目地址部署的方案都在腳本里頭,說(shuō)明如下使用方法版本簡(jiǎn)單介紹是一個(gè)利用轉(zhuǎn)發(fā)操作系統(tǒng)中部署的基于框架和框架以及一個(gè)的服務(wù)。個(gè)服務(wù)是部署在環(huán)境中,通過(guò)和進(jìn)行發(fā)送和接收消息。在前臺(tái)以及整個(gè)主要利用去操作。 項(xiàng)目地址:https://github.com/yuyangit/BMProject 部署的方案都在腳本里頭,說(shuō)明如下: BMPlatform使用方法 版本 v0.2 1.簡(jiǎn)單介紹...
閱讀 2091·2019-08-30 15:53
閱讀 3083·2019-08-30 15:44
閱讀 2941·2019-08-30 14:11
閱讀 2935·2019-08-30 14:01
閱讀 2726·2019-08-29 15:16
閱讀 3795·2019-08-29 13:10
閱讀 1269·2019-08-29 10:56
閱讀 2554·2019-08-26 13:58