IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Debian使用Supervisor守护进程

    pipu发表于 2023-07-30 06:17:13
    love 0

    前言

    之前用宝塔面板的时候可以直接在“应用商店”安装Supervisor,现在换了1panel面板,使用代码也可轻松实现进程的守护。

    简介

    Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。

    安装

    Debian安装supervisor

    apt-get update
    apt-get install supervisor

    配置文件

    Supervisor的配置文件为/etc/supervisor/supervisord.conf
    Supervisor所管理应用的配置文件放在/etc/supervisor/conf.d/目录中,需要对每个应用进行配置。在/etc/supervisor/conf.d/中创建xxxxxx.conf,每个应用对应一个配置文件即可。

    conf文件内容示例:

    [program:cloudreve]
    command=/pipu/cloudreve/cloudreve
    directory=/pipu/cloudreve/
    user = root
    stopsignal = INT
    autostart = true
    autorestart = true
    startsecs = 1
    stderr_logfile = /var/log/cloudreve.err.log

    添加开机启动Debin

    systemctl enable supervisor

    启动Supervisor

    supervisorctl start all

    常用命令

    supervisorctl shutdown #关闭所有任务
    supervisorctl stop|start program_name #关闭指定任务
    supervisorctl status #查看所有任务状态
    supervisorctl update #加载新的配置
    supervisorctl reload #重启所有任务



沪ICP备19023445号-2号
友情链接