首页 > 其他分享 >Some demos of supervisor conf

Some demos of supervisor conf

时间:2023-06-08 15:45:10浏览次数:42  
标签:supervisor -- Some myproject demos ubuntu home logfile true

conf files in /etc/supervisor/conf.d/

Version

Supervisor is installed by apt, and it's version is:

sudo supervisord --version
4.1.0

Conf files

There are Django projects, FastAPI projects, Celery beat and worker in the cloud server

  1. Django Project
  • /etc/supervisor/conf.d/myproject.conf
[program:myproject]
environment =
  APP_SECRET=asdf234asdf234dafasdf2342adsf,
  SECRET_KEY="4+k*s7#1w3d#l2rg@5lajy4*asf(sasdf]sf}"
command=/home/ubuntu/coding/myproject/gunicorn_start.sh --reload
stdout_logfile=/home/ubuntu/coding/myproject/supervisor.log
directory=/home/ubuntu/coding/myproject
user=ubuntu

numprocs=1
autostart=true
startsecs=10
autorestart=true
startretried=3
redirect_stderr=true
stdout_logfile_backups=20
stdout_logfile_maxbytes=20MB
  • /home/ubuntu/myproject/gunicorn_start.sh
#! /bin/bash

PORT=5920
BASE="/home/"
FULL_PATH=`realpath .`
PROJECT=${FULL_PATH##*/}
HOME_PATH=`realpath ../..`
USER=${HOME_PATH#$BASE}
DIR=/home/$USER/coding/$PROJECT
WORKERS=2
BIND=127.0.0.1:$PORT
DJANGO_SETTINGS_MODULE=$PROJECT.settings
DJANGO_WSGI_MODULE=$PROJECT.wsgi
LOG_LEVEL=info

cd $DIR

export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE

exec poetry run gunicorn ${DJANGO_WSGI_MODULE} \
    --workers $WORKERS \
    --user=$USER \
    --bind=$BIND \
    --log-level $LOG_LEVEL\
    --access-logfile '-'\
    --access-logformat '[%(h)s] "%(r)s" %(s)s %(L)s "%(f)s"' \
    $*

注:使用gunicorn_start.sh可以简化supervisor中的command配置

  • poetry
pip install pipx --user
pipx install poetry
export PATH=$PATH:$HOME/.local/bin
sudo ln -s /usr/bin/poetry `which poetry`
  1. FastAPI Project
[program:myapi]
command=poetry run gunicorn main:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:9817 --reload
directory=/home/ubuntu/coding/myapi
stdout_logfile=/home/ubuntu/coding/myapi/supervisor.log
user=ubuntu

numprocs=1
autostart=true
startsecs=10
autorestart=true
startretried=3
redirect_stderr=true
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20

注:uvicorn要用gunicorn来挂载,否则有可能导致CPU和内存占用过多

  1. Celery worker
[program:myprojectcelery]
command=/usr/bin/poetry run celery -A myproject worker -l info --concurrency=8
directory=/home/ubuntu/coding/myproject
stdout_logfile=/home/ubuntu/coding/myproject/celery.log
numprocs=1
autostart=true
startsecs=10
autorestart=true
startretried=3
user=ubuntu
redirect_stderr=true
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20
  1. Celery beat
[program:myprojectbeat]
command=/usr/bin/poetry run celery -A myproject beat
directory=/home/ubuntu/coding/myproject
numprocs=1
autostart=true
startsecs=10
autorestart=true
startretried=3
user=ubuntu
redirect_stderr=true
stdout_logfile=/home/ubuntu/coding/myproject/celerybeat.log
stdout_logfile_maxbytes=20MB
stdout_logfile_backups=20

标签:supervisor,--,Some,myproject,demos,ubuntu,home,logfile,true
From: https://www.cnblogs.com/waketzheng/p/17466669.html

相关文章

  • 【Exception】The dependencies of some of the beans in the application context fo
    案发现场***************************APPLICATIONFAILEDTOSTART***************************Description:Thedependenciesofsomeofthebeansintheapplicationcontextformacycle:┌─────┐|asyncConfigdefinedinfile[E:\code\spring-boot-demo\t......
  • Qt第六十二章:图标库QtAwesome的使用
    目录一、安装依赖二、主页三、文档四、案例1、图标2、样式3、alpha通道4、多图标堆叠5、动画6、字体五、系列1、msc系列2、fa5系列(选择free栏)3、fa5s系列(选择free栏)4、fa5b系列(选择free栏)5、fa系列6、ei系列7、mdi系列8、mdi6系列9、ph系列10、ri系列一、安装依赖pipinstallQtA......
  • Font-AweSome在Vue中的使用
    Font-AweSome在Vue中的使用yarnaddfont-awesome或者npmifont-awesome-S在main.js中引入import'font-awesome/css/font-awesome.min.css'Vue中使用<iclass="fafa-camera-retro"></i> ......
  • selenium-some code
     ======================================fromseleniumimportwebdriverdriver=webdriver.Chrome()driver.get("http://selenium.dev")#driver.quit() fromseleniumimportwebdriveroption=webdriver.ChromeOptions()option.add_experimental......
  • 循环依赖导致编译或者服务启动报错问题:The dependencies of some of the beans in the
    错误如图: 我的是服务器启动服务时报错:***************************APPLICATIONFAILEDTOSTART***************************Description:Thedependenciesofsomeofthebeansintheapplicationcontextformacycle报错原因:两个类相互引用对方,导致Spring在初始化b......
  • vue3 打包超出限制 Some chunks are larger than 500 kBs after minification
    vite.config.ts,build:{//如果自己分片的话,就会生成37个文件//chunkSizeWarningLimit:1000,//rollupOptions:{//output:{//manualChunks(id){//if(id.includes('node_modules')){//re......
  • supervisor使用详解
    一介绍使用文档:http://supervisord.org/supervisor是Python开发的c/s服务,是Linux系统下的进程管理工具。可以监听、启动、停止、重启一个或多个进程用supervisor管理的进程,当一个进程意外被杀死,supervisor监听到进程死后,会自动将它重启,很方便的做到进程的自动恢复的功能,不在......
  • docker 安装 ha supervisor [aarch64]
    克隆镜像下载hassio-supervisor,homeassistant镜像打开网址下面两个网址,获取最新版本镜像,使用dockerpull拉取镜像https://github.com/home-assistant/supervisor/pkgs/container/aarch64-hassio-supervisorhttps://github.com/home-assistant/core/pkgs/container/aarch64......
  • spring出现依赖关系形成循环问题,The dependencies of some of the beans in the appli
    出现这个问题大多使用的springboot都是在2.6.x以上,springboot在2.6.x就将依赖循环禁用了,解决方式有以下几种:解决方式:1、第一种解决方式:可以优化自己程序的逻辑,优化bean的依赖关系,只要不形成一个环状就不会出该问题了 2、第二种解决方式:可以使用@Lazy注解(懒加载)和@Autowired注......
  • JS中some和every的区别和用法
    some和every是数组中迭代的方法相同点:some和every都有三个参数,即item→当前项,index→当前的索引值,array→数组本身;都可以遍历数组不同点:some相当于逻辑关系中的或,只要有一个参数满足条件,则中断遍历,返回true,如果遍历完所有参数,没有找到符合的项,即返回false;every相当于关系中的且,......