图文摘要

安装进程管理程序

树莓派4b安装supervisor

作者: 来源: 发布时间:2022-10-25 00:39:09

Supervisor安装与配置(linux/unix进程管理工具) Supervisor(Supervisor: A Process Control System)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制。

安装步骤

  1. 安装supervisor程序监控工具软件 命令为:sudo apt install supervisor
  2. 安装完成后进入supervisor 的配置目录:cd /etc/supervisor/conf.d
  3. 创建supervisor配置文件,格式为:xxxx.conf

注意:.conf文件的名称自己设置,最好跟实际使用的程序挂钩,方便理解

配置.conf文件,内容格式如下:

# 新建一个应用并设置一个名称,这里设置为 hyperf
[program:hyperf]
# 设置命令在指定的目录内执行
directory=/ss/hyperf/
# 这里为您要管理的项目的启动命令
command=php ./bin/hyperf.php server:watch
# 以哪个用户来运行该进程
user=root
# supervisor 启动时自动该应用
autostart=true
# 进程退出后自动重启进程
autorestart=true
# 进程持续运行多久才认为是启动成功
startsecs=1
# 重试次数
startretries=3
# stderr 日志输出位置
stderr_logfile=/ss/hyperf/runtime/stderr.log
# stdout 日志输出位置
stdout_logfile=/ss/hyperf/runtime/stdout.log

常用命令:

# 启动 hyperf 应用
supervisorctl start hyperf
# 重启 hyperf 应用
supervisorctl restart hyperf
# 停止 hyperf 应用
supervisorctl stop hyperf  
# 查看所有被管理项目运行状态
supervisorctl status
# 重新加载配置文件
supervisorctl update
# 重新启动所有程序
supervisorctl reload