1.安装 supervisor
pip install supervisor
2.创建supervisor配置文件,命令如下:
进入项目文件
echo_supervisord_conf > supervisord.conf
vim supervisord.conf
在末尾输入:
[program:celeryd] # 进程的名字
command=/opt/python/bin/celery worker -A worker --loglevel=info stdout_logfile=/django/celery/celeryd.log stderr_logfile=/django/celery/celeryd.log autostart=true autorestart=true startsecs=10 stopwaitsecs=600
[program: ProjectName]
command=dotnet ProjectName.dll ; 运行程序的命令
directory=/root/Publishing/PublishOutput/ ; 命令执行的目录
autorestart=true ; 程序意外退出是否自动重启
autostart=true ; 是否自动启动
stderr_logfile=/var/log/ProjectName.err.log ; 错误日志文件
stdout_logfile=/var/log/ProjectName.out.log ; 输出日志文件
environment=ASPNETCORE_ENVIRONMENT=Production ; 进程环境变量
user=root ; 进程执行的用户身份
stopsignal=INT
startsecs=1 ; 自动重启间隔
在Django 目录下执行
supervisord
supervisorctl 命令
在启动后台执行之后,可以使用supervisorctl命令查看后台的日志信息,以及重启服务。
$ supervisorctl tail celeryd # 查看最后的日志
$ supervisorctl tail -f celeryd # 持续
$ supervisorctl restart celeryd
$ supervisorctl status celeryd
$ supervisorctl start celeryd
$ supervisorctl stop celeryd
3.supervisorctl查看和停止supervisor的状态: 报错后可查看 /django/celery/celeryd.log
supervisorctl status # 查看状态 reread # 读取配置信息 update # 加载最新的进程 stop # 停止进程 start # 启动进程 reload # 重新加载配置
程序员求职之道(《程序员面试笔试宝典》)之程序设计基础(内存分配形式)?
程序员求职之道(《程序员面试笔试宝典》)之智力题攻略?(称重类智力题)
程序员求职之道(《程序员面试笔试宝典》)之海量数据处理(排序问题)?
程序员求职之道(《程序员面试笔试宝典》)之优秀程序员应该具备哪些素质?
如何能把知识变现
民企赚一元,五毛都交了税
企业的核心竞争力是什么
未来将有50%人失业
培养管理人才重在教育