Centos7安装supervisor详细教程

2023-11-17

supervisor:要安装的软件的名称。
supervisord:装好supervisor软件后,supervisord用于启动supervisor服务。
supervisorctl:用于管理supervisor配置文件中program和supervisor服务本身。

方法一、使用yum命令安装(推荐)

$ sudo su - #切换为root用户
# yum install epel-release
# yum install -y supervisor
# systemctl enable supervisord # 开机自启动
# systemctl start supervisord # 启动supervisord服务

# systemctl status supervisord # 查看supervisord服务状态
# ps -ef|grep supervisord # 查看是否存在supervisord进程

方法二、使用pip手工安装配置(不推荐)

准备工作

确认9001端口未被占用,如果9001端口被占用,请将后面提到的supervisord.conf文件中的9001替换为可用端口号,如7001。

一、安装supervisor

切换为root用户

$ sudo su -

为python2.7安装pip(supervisor只支持python2.7)

(1) 下载pip

# wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate

(2) 安装pip

# python2.7 get-pip.py

如果遇到psutil相关的报错,参考

https://www.cnblogs.com/chentq/p/4954135.html
安装supervisor

创建supervisor所需目录

# mkdir /etc/supervisord.d/

创建supervisor配置文件

# echo_supervisord_conf > /etc/supervisord.conf

编辑supervisord.conf文件

# vim /etc/supervisord.conf

文件内容如下(直接展示完整的文件内容,建议直接复制粘贴,如果想知道详细改动,可逐行对比)

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
;  - Shell expansion ("~" or "$HOME") is not supported.  Environment
;    variables can be expanded using this syntax: "%(ENV_HOME)s".
;  - Quotes around values are not supported, except in the case of
;    the environment= options as shown below.
;  - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
;  - Command will be truncated if it looks like a config file comment, e.g.
;    "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".

[unix_http_server]
file=/var/run/supervisor.sock   ; the path to the socket file
;chmod=0700                 ; socket file mode (default 0700)
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[supervisord]
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
logfile_maxbytes=50MB        ; max main logfile bytes b4 rotation; default 50MB
logfile_backups=10           ; # of main logfile backups; 0 means none, default 10
loglevel=info                ; log level; default info; others: debug,warn,trace
pidfile=/var/run/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=false               ; start in foreground if true; default false
minfds=1024                  ; min. avail startup file descriptors; default 1024
minprocs=200                 ; min. avail process descriptors;default 200
;umask=022                   ; process file creation umask; default 022
;user=chrism                 ; default is current user, required if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/tmp              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/tmp            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false

; The rpcinterface:supervisor section must remain in the config file for
; RPC (supervisorctl/web interface) to work.  Additional interfaces may be
; added by defining them in separate [rpcinterface:x] sections.

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The supervisorctl section configures how supervisorctl will connect to
; supervisord.  configure it match the settings in either the unix_http_server
; or inet_http_server section.

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available

; The sample program section below shows all possible program subsection values.
; Create one or more 'real' program: sections to be able to control them under
; supervisor.

;[program:theprogramname]
;command=/bin/cat              ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=999                  ; the relative start priority (default 999)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=true          ; redirect proc stderr to stdout (default false)
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A="1",B="2"       ; process environment additions (def no adds)
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample eventlistener section below shows all possible eventlistener
; subsection values.  Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener    ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1                    ; number of processes copies to start (def 1)
;events=EVENT                  ; event notif. types to subscribe to (req'd)
;buffer_size=10                ; event buffer queue size (default 10)
;directory=/tmp                ; directory to cwd to before exec (def no cwd)
;umask=022                     ; umask for process (default None)
;priority=-1                   ; the relative start priority (default -1)
;autostart=true                ; start at supervisord start (default: true)
;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)
;startretries=3                ; max # of serial start failures when starting (default 3)
;autorestart=unexpected        ; autorestart if exited after running (def: unexpected)
;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT               ; signal used to kill process (default TERM)
;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false             ; send stop signal to the UNIX process group (default false)
;killasgroup=false             ; SIGKILL the UNIX process group (def false)
;user=chrism                   ; setuid to this UNIX account to run the program
;redirect_stderr=false         ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path        ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10     ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false   ; emit events on stdout writes (default false)
;stderr_logfile=/a/path        ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10     ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false   ; emit events on stderr writes (default false)
;environment=A="1",B="2"       ; process environment additions
;serverurl=AUTO                ; override serverurl computation (childutils)

; The sample group section below shows all possible group values.  Create one
; or more 'real' group: sections to create "heterogeneous" process groups.

;[group:thegroupname]
;programs=progname1,progname2  ; each refers to 'x' in [program:x] definitions
;priority=999                  ; the relative start priority (default 999)

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisord.d/*.ini

保存退出

Esc:x

启动supervisor

# supervisord -c /etc/supervisord.conf

查看supervisor是否启动成功

# ps -ef|grep supervisord
root       932     1  0 May10 ?        00:00:09 /bin/python2.7 /bin/supervisord -c /etc/supervisord.conf
root      7902  6814  0 10:29 pts/0    00:00:00 grep --color=auto supervisord

二、将supervisor配置为开机自启动服务

编辑服务文件

# vim /usr/lib/systemd/system/supervisord.service

内容如下

[Unit]
Description=Supervisor daemon

[Service]
Type=forking
PIDFile=/var/run/supervisord.pid
ExecStart=/bin/supervisord -c /etc/supervisord.conf
ExecStop=/bin/supervisorctl shutdown
ExecReload=/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

保存退出

Esc:x

启动服务

# systemctl enable supervisord

查看是否启动

# systemctl is-enabled supervisord
enabled

成功之后,就可以使用如下命令管理supervisor服务了

# systemctl stop supervisord
# systemctl start supervisord
# systemctl status supervisord
# systemctl reload supervisord
# systemctl restart supervisord

补充:

因为我们的supervisor使用的是root安装,所以,对于非root用户,如果在执行

 $ supervisord -c /etc/supervisord.conf 
 $ supervisorctl

命令时,会遇到访问被拒(Permission denied)的问题。
在命令最前面加上sudo即可
2. 如果更改了/etc/supervisord.conf中的端口号,原来的简写命令

# supervisorctl

就需要在后面指定supervsor配置文件位置,或指定supervisor服务运行的端口号

# supervisorctl -c /etc/supervisord.conf 
# supervisorctl -s http://localhost:7001

否则会报连接拒绝

# supervisorctl 
http://localhost:9001 refused connection
supervisor> 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Centos7安装supervisor详细教程 的相关文章

  • 从浏览器输入网址到显示页面之间发生了什么

    好久没有更博了 最近一直忙于春招实习应聘 似乎有些打乱了我的节奏 我觉得还是应该把重心放在学习和记录上 不管有没有实习或者有没有拿到offer 我都一直stand by 言归正传 当你输入一个网址到页面显示在你眼前到底发生了什么 这其实是个
  • ESP8266 教程3 — 通过TCP组建局域网并通信

    目录 1 ESP8266 的 AP 模式 1 1 查询 ESP8266 的wifi应用模式 1 2 设置 ESP8266 模块的wifi信息 1 3 查询已经接入的设备 2 ESP8266 的Station 模式 2 1 设置ESP8266
  • FusionCompute8.0.0实验(1)CNA及VRM安装

    准备 1 老旧华硕笔记本电脑用于安装CNA 内存8G 硬盘1T 24G固态 i7 4500u 2核4线程 2 USB光驱 电脑上的光驱坏了 CNA不支持U盘安装 5V2A外接适配器 不能用快充 3 ultroISO破解版 4 办公笔记本 1
  • 阿里云服务器包年包月、按量和抢占式实例怎么选?区别是什么?

    阿里云服务器ECS付费类型包年包月 按量付费和抢占式实例有什么区别 包年包月先付费后使用 最低购买一个月时长 平均下来成本较低 按量付费先使用后付费 按小时结算费用 适合短期使用 平均下来费用要比包年包月贵一些 抢占式实例和按量付费相类似
  • 网站前台技术

    一 HTML5 1 历史 2 应用 html5语法 1 标签不区分大小写2 允许属性值不使用引号3 允许部分属性值的属性省略 html标记 带有 lt gt 符号的元素被称为HTML标记 也称为HTML标签或HTML元素 例如 都是HTML
  • Android选择本地视频和照片上传到服务器

    目录 照片photo 将http 本地存放照片数据库电脑ip 端口号 fileaddress png转image 一 后台发送来的数据转换Bitmap的方法 用法 二 将第一针显示出来方法 用法 视频vedio 使用选择器获取的 conte
  • rpm打包流程步骤

    rpm打包流程步骤 一 RPM简介 1 1 优点 1 2 缺点 二 前期准备 三 文件结构 3 1 各文件作用 四 打包步骤及SPEC文件的编辑 4 1 步骤 4 1 1 前期准备 4 1 2 建立相应的文件 4 1 3 将源码包放入SOU
  • 2.微服务架构组件分析

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 该系列文章来源于 学习 极客时间 从0开始学习微服务 分享之后笔记载录和读后感 作者胡忠想 微博技术专家 从 2012 年加入微博到现在 从 2012 年加入微博到现在 我
  • blender的下载安装和配置中文环境

    引言 在3D建模和动画设计领域 Blender 作为一款强大且免费的开源软件 一直以优秀的性能和对众多技术的支持赢得了大批用户的喜爱 然而 对于刚接触这款软件的用户而言 其安装和配置过程可能会带来一定困扰 尤其是在设置中文环境方面 因此 本
  • Python 爬虫初学者实战

    1 手写第一个 python 爬虫 爬虫 用程序来获取网站上的资源 常用 encoding utf 8 encoding gbk 1 导入 urllib request urlopen from urllib request import
  • Swiper 显示多行多列

    new Swiper popularity container speed 1600 autoHeight true observer true observeParents true spaceBetween 20 slidesPerVi
  • YOLOv1,v2,v3学习笔记

    YOLO学习笔记 首先我们这篇文章只写yolov1 v2 v3 至于v4我会另起一篇博文的 因为v4中用到了很多的trick和介绍了很多trick 所以我想详细介绍一下 照例 先放大佬的链接 https zhuanlan zhihu com
  • 【数字电路基础】三态门

    目录 前言 三态门 经典问题 前言 文主要讲解三态门 三态门 其模型为 其实际电路为 其真值表为 B A C 0 0 Z 0 1 Z 1 0 0 1 1 1 注意 Z是高阻 不代表没有电压 而是电压不确定 受自身 旁边cell的影响 经典问
  • multi-head attention理解加代码

    multi head attention 用于CNN相关理解 饭前小菜 在早期的Machine Translation 机器翻译 中 Attention机制与RNN的结合 机器翻译解决的是输入是一串在某种语言中的一句话 输出是目标语言相对应
  • python通过多进程加快预处理数据集的速度

    问题背景 imageNet数据集有1000个文件夹 每个文件夹是同一类的图片 大概一两千张 需要对每张图片进行预处理 把图片变成224 224像素的 这样可以加速后续程序的IO速度 同时也方便了数据集的移动 因为更小了 但是图片数量很大 全
  • 工具功能加强-对ARL的改造

    这一阵挖了不少的洞 学习到了很多的姿势 对ARL 玩的也明白了些 下面给大家介绍下如何加强你的ARL 首先不熟悉ARL的可以访问ARL的地址 GitHub TophantTechnology ARL ARL Asset Reconnaiss
  • 嘉兴职业技术学校2019分数线计算机,嘉兴职业技术学院

    序号 入围专业 分数线 1 园艺技术 131 43 2 应用电子技术 航空电子方向 130 00 3 无人机应用技术 125 14 4 物流管理 航空物流方向 133 14 5 旅游管理 文化创意与策划方向 129 14 6 酒店管理 休闲
  • Ubuntu apt update 报错APT::Update::

    E Problem executing scripts APT Update Post Invoke Success if usr bin test w var cache app info a e usr bin appstreamcli
  • 2021年开始,Adobe Flash Player 不能用了?

    WeChat 网管小贾 www sysadm cc 我们都知道 Adobe Flash Player 以下简称 Flash 是比较古老的程序了 在80 90后一代的记忆中 Flash 曾经可是火得一塌糊涂 而炙手可热的 Flash 很多人都
  • jmp address windows hook

    以下代码是sysnap早期发表的inlinehook ObReferenceObjectByHandle 的代码 大部分看懂了 但是有些看不懂 google也查了 qq群也问了 哪位高手有时间给科普下哈 可怜下偶们菜鸟吧 declspec

随机推荐

  • 【Spring IoC容器的加载过程】

    加载配置文件 Spring IoC容器的配置通常以XML形式存储 并通过ResourceLoader和XmlBeanDefinitionReader类来加载 ResourceLoader主要负责加载Bean配置文件 而XmlBeanDefi
  • Java字符串分析器

    package StruingTokenizer import java util StringTokenizer public class StringTokenizer public static void main String ar
  • Docker-数据卷(Data Volumes)&dockerfile

    目录 一 宿主机与容器之间的文件拷贝 1 1 容器中怎么上传项目 文件 1 2 从宿主机拷贝文件到容器 1 3 从容器中拷贝文件到宿主机 二 数据卷 三 数据卷容器 四 Dockerfile Dockerfile制作增强版 自定义cento
  • 电商前台项目——完成注册登录功能、路由守卫

    电商前台项目 完成注册登录功能 路由守卫 文章目录 电商前台项目 完成注册登录功能 路由守卫 一 完成注册部分 1 获取验证码 2 完成用户注册 二 登录 1 点击登录发送请求校验 2 保存下发的token 3 拿着token请求用户数据并
  • 音频处理工具SOX详解

    这里写自定义目录标题 前言 一 简介 二 基本使用 三 音频效果 前言 SoX 即 Sound eXchange 是一个跨平台 Windows Linux MacOS 等 的命令行实用程序 可以将各种格式的音频文件转换为需要的其他格式 So
  • 分布式事务的 N 种实现

    需求缘起 在微服务架构中 随着服务的逐步拆分 数据库私有已经成为共识 这也导致所面临的分布式事务问题成为微服务落地过程中一个非常难以逾越的障碍 但是目前尚没有一个完整通用的解决方案 其实不仅仅是在微服务架构中 随着用户访问量的逐渐上涨 数据
  • Spring Cloud (各厂)

    参考 https zhuanlan zhihu com p 98874444 Spring Cloud Netflix Spring Cloud 官方 Spring Cloud Zookeeper Spring Cloud Consul K
  • 【数据结构与算法】不就是数据结构

    前言 嗨喽小伙伴们你们好呀 好久不见了 我已经好久没更新博文了 之前因为实习没有时间去写博文 现在已经回归校园了 我看了本学期的课程中有数据结构这门课程 这么课程特别重要 因为之前学过一点 所以就想着深入学习一下子 毕竟这门课程对于考研和就
  • 基于卷积神经网络进行股价预测(Matlab代码实现)

    目录 1 概述 2 运行结果 3 参考文献 4 Matlab代码 1 概述 CNN是一种人工神经网络 CNN的结构可以分为3层 卷积层 Convolutional Layer 主要作用是提取特征 池化层 Max Pooling Layer
  • C/C++中for循环详解,以及括号中三部分内容的含义和C++11标准for方法

    for循环语句 作用 满足循环条件 执行循环语句 语法 for 起始表达式 条件表达式 末尾循环体 循环语句 格式 for init statement condition expression statement 解析 init stat
  • C# 学习笔记

    不再是学生了 成了社畜了 公司主要技术栈是C 大一时候学C 学的很迷糊 总要重新学一下 入职已经20天了 也开始上手简单增删改查了 记录了一些C 相关的东西 只是还没有系统整理 WinForm 控件命名规范 ADO NET 连接数据库 Co
  • python与人工智能:神经网络和深度学习,卷积神经网络识别手写文字

    深度学习是用于建立 模拟人脑进行分析学习的神经网络 并模仿人脑的机制来解释数据的一种机器学习 技术 卷积神经网络是其中最火热的技术 如果要做事 想赶快入门 速度出活 请先死记住 深度学习 多层的神经网络 如果要写论文 要作报告 要闲聊 请坚
  • Python实现长短记忆神经网络(LSTM)预测经验模态分解(EMD)各模态变化的组合时间序列预测模型

    本实验使用环境为Anaconda3 Jupyter 调用Sklearn包 Keras包 请提前准备好 只提供数据格式而不提供数据 本人是代码缝合怪小白 望大牛指点 1 导包 主要包含pandas numpy 绘图包 日期格式 数学计算 py
  • 2022-2027年中国老年健康服务行业发展监测及投资战略研究报告

    报告类型 产业研究 报告格式 电子 纸介版 出品单位 华经产业研究院 本报告由华经产业研究院重磅推出 对中国老年健康服务行业的发展现状 竞争格局及市场供需形势进行了具体分析 并从行业的政策环境 经济环境 社会环境及技术环境等方面分析行业面临
  • Python配置VTK库

    方法一 安装anaconda 使用conda install安装 注意不同版本的Python对应不同的命令 适用于python3 3 6以下 install n envA c menpo vtk 7 python 3 or if you w
  • 使用IDEA实现java生成随机验证码

    package test200 checkCode 需求 定义方法实现随机产生一个5位的验证码 每位可能是数字 大写字母 小写字母 分析 定义一个方法 生成验证码返回 方法参数是位数 方法的返回值类型是String 在方法内部使用for循环
  • Flutter卡packages get解决方法(附默认插件地址及国内镜像修改)

    Flutter卡packages get解决方法 附默认插件地址及国内镜像修改 问题描述 发现原因 解决问题 本篇主要讲述Mac环境下的配置 其他操作系统的用户可相应参考 问题描述 为项目添加新的依赖包 一直卡flutter pub get
  • 吴恩达机器学习(九)Precision、Recall、F-score、TPR、FPR、TNR、FNR、AUC、Accuracy

    目录 0 前言 1 Precision Recall F score F measure 2 TPR FPR TNR FNR AUC 3 Accuracy 学习完吴恩达老师机器学习课程的机器学习系统设计 简单的做个笔记 文中部分描述属于个人
  • [转载]2014年Windows平台软件推荐:神器小工具(骨灰级)

    底层工具 If you know how to use Process Monitor competently people of both sexes will immediately find you more attractive S
  • Centos7安装supervisor详细教程

    supervisor 要安装的软件的名称 supervisord 装好supervisor软件后 supervisord用于启动supervisor服务 supervisorctl 用于管理supervisor配置文件中program和su