7---性能優(yōu)化(2)

supervisord守護(hù)進(jìn)程

  • 安裝
sudo apt-get install supervisor
echo_supervisord_conf
cat /etc/supervisord/supervisord.conf
  • 檢查 supervisord.conf 末行
[include]
files = /etc/supervisor/conf.d/*.conf
files = conf.d/*.conf
  • 檢查 supervisored.conf 末行
;[include] 
files = /etc/supervisor/*.conf
  • 自定義文件.config
[program:django_celery]

user                    = root
# environment             = PATH = "/root/.virtualenvs/cui_web/bin/"

directory               = /root/cui_web/zhizhi_kernel/  ; 命令所在目錄

command                 = /root/.virtualenvs/cui_web/bin/python manage.py celery worker -c 4 --loglevel= info

startsecs               = 0             ;啟動時(shí)間                                   
stopwaitsecs            = 0             ; 終止等待時(shí)間
autostart               = true          ; 是否自啟動
autorestart             = true          ; 是否自重啟

stdout_logfile_maxbytes = 20MB ;日志...
stderr_logfile_maxbytes = 20MB
stdout_logfile_backups  = 10
stderr_logfile_backups  = 10

stderr_logfile          = /root/cui_web/zhizhi_kernel/log/supervisor_err.log
stdout_logfile          = /root/cui_web/zhizhi_kernel/log/supervisor_out.log
loglevel                = info          ; 日志級別


盡量在目錄下使用命令

  • 開啟服務(wù)
sudo supervisord -c supervisord.conf
若不在目錄下
sudo supervisord -c /etc/supervisor/supervisord.conf
指定服務(wù)
sudo supervisorctl start 你的服務(wù)
>>! 正確結(jié)果
>>> $sudo supervisorctl -c supervisord.conf
>>> django_celery     RUNNING   pid 1398, uptime 0:00:00
>>> $supervisorctl  status
>>> django_celery     RUNNING   pid 2017, uptime 0:00:01
  • 關(guān)閉服務(wù)
sudo ps -aux|grep super*
kill -9 xxx
  • 服務(wù)常用指令
supervisorctl status        //查看所有進(jìn)程的狀態(tài)
supervisorctl stop es       //停止es
supervisorctl start es      //啟動es
supervisorctl restart       //重啟es
supervisorctl update        //配置文件修改后使用該命令加載新的配置
supervisorctl reload        //重新啟動配置中的所有程序
  • 注意--清除 .pyc文件與__pycache__.py文件的緩存
  • 注意--遷移 python manage.py migrate 生成遷移數(shù)據(jù)庫
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容