supervisor--go版安装

news/2024/7/24 5:06:37 标签: golang, linux

系统环境

ubuntu18.04

安装

golang_3">1、下载指定golang版本的安装包

安装包下载地址:https://github.com/ochinchina/supervisord/releases/tag/v0.7.3

1.1、构建supervisor的目录结构

mkdir -p /etc/supervisord/conf.d

1.2、supervisor的目录结构

在这里插入图片描述

1.3、说明

目录中的supervisord二进制文件为上面安装包中的二进制文件

2、配置

2.1 添加启动所需配置文件

配置文件路径
/etc/supervisord/supervisord.conf
配置文件内容
[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ;(main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ;(supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
logfile_maxbytes=50MB        ;日志文件大小,超出会rotate,默认 50MB,如果设成0,表示不限制大小
logfile_backups=10           ;日志文件保留备份数量默认10,设为0表示不备份
loglevel=info                ;日志级别,默认info,其它: debug,warn,trace
nodaemon=false               ;是否在前台启动,默认是false,即以 daemon 的方式启动
minfds=1024                  ;可以打开的文件描述符的最小值,默认 1024
minprocs=200                 ;可以打开的进程数的最小值,默认 200

; the below 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: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; 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.

[inet_http_server]
port=0.0.0.0:9001

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

2.2 将需要后台运行的程序挂载到配置文件

(此处是配置模板,请根据自己需求自行配置)

## 将需要挂载到后台运行的配置文件放置到 /etc/supervisord/conf.d/alter.conf
# 例如:altermanager
[program:alertmanager]
# 程序所在目录
directory = /opt/project/alertmanager/
# 启动程序的命令;
command = /opt/project/alertmanager/alertmanager --config.file=/opt/project/alertmanager/alertmanager.yml --cluster.advertise-address=0.0.0.0:9093
# 在supervisord启动的时候也自动启动;
autostart = true
# 程序异常退出后自动重启;
autorestart = true
# 启动5秒后没有异常退出,就当作已经正常启动了;
startsecs = 5
# 启动失败自动重试次数,默认是3;
startretries = 3
# 启动程序的用户;
user = root
# 把stderr重定向到stdout,默认false;
redirect_stderr = true
# 标准日志输出;
stdout_logfile=/tmp/alertmanager_stdout.log
# 错误日志输出;
stderr_logfile=/tmp/alertmanager_stderr.log
# 标准日志文件大小,默认50MB;
stdout_logfile_maxbytes = 20MB
# 标准日志文件备份数;
stdout_logfile_backups = 20

2.3 将服务加入到系统服务system中

2.3.1 命令
vim  /etc/systemd/system/supervisord.service
2.3.2 内容
[Unit]
Description=supervisord service in golang
After=network.target
 
[Service]
Type=simple
User=root
StartLimitInterval=5
StartLimitBurst=10
ExecStartPre=/bin/sleep 10
ExecStart=/etc/supervisord/supervisord -c /etc/supervisord/supervisord.conf
Restart=always
RestartSec=120
 
[Install]
WantedBy=multi-user.target
2.3.3 加载新配置
systemctl daemon-reload
systemctl start  supervisord.service
systemctl status supervisord

2.4 简化命令

2.4.1 打开配置文件
vim  /etc/profile
2.4.2 文件中追加当前命令
alias supervisorctl='/etc/supervisord/supervisord ctl'
2.4.3 使配置生效
source /etc/profile

借鉴链接


http://www.niftyadmin.cn/n/5101892.html

相关文章

[python 刷题] 138 Copy List with Random Pointer

[python 刷题] 138 Copy List with Random Pointer 题目: A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. Construct a deep copy of the list. The deep …

利用服务器打造创新的在线社区

在这个数字化时代,服务器是实现创意项目的关键工具之一。虽然有许多用途,但其中最引人注目的是将服务器用于构建创新的在线社区。 为什么选择在线社区? 在线社区是连接人们、促进互动和分享知识的强大工具。它们可以围绕共同的兴趣、目标或…

Python之并发编程(线程)

文章目录 一、线程理论二、开设线程的两种方式 一、线程理论 什么是线程 进程:资源单位 线程:执行单位进程相当于车间(一个个空间),线程相当于车间里面的流水线(真正干活的)一个进程中至少有一个线程"""进程仅仅是在内存中开辟一块空间(提供线程工作…

找寻openSUSE的前世今生

找寻开始的地方 在一些资产管理平台、网管系统,完全依赖资产录入资产,假如存在SUSE类型网元,能否将SLES和openSUSE一同接入到SUSE类型下,就有待商榷了。 SLES和openSUSE是两个不同的Linux发行版,更准确说是两个不同的…

SpringCloud学习笔记-gateway网关自定义全局过滤器

需求:定义全局过滤器,拦截请求,判断请求的参数是否满足下面条件: 参数中是否有authorization, authorization参数值是否为admin 如果同时满足则放行,否则拦截 实现: 在gateway中定义一个过…

工控机通过485modbus转profinet网关与温度智能表通讯配置案例

在这个案例中,通过485modbus转profinet网关(XD-MDPN100)可以实现工控机与温度智能表之间的双向通信。工控机通过modbus协议将温度数据发送到网关,网关将数据转换为profinet协议后发送给温度智能表进行显示和控制。 通过485modbus转…

HiveServer2负载均衡

有多个HiveServer2服务时,可以借助Zookeeper服务实现访问HiveServer2的负载均衡,将HiveServer2的压力分担到多个节点上去。本文详细介绍HiveServer2负载均衡的配置及使用方法,请根据EMR集群(普通集群和Kerberos集群)的…

CCF计算机资格认证模拟题202303-2垦田计划

问题描述 顿顿总共选中了 块区域准备开垦田地,由于各块区域大小不一,开垦所需时间也不尽相同。据估算,其中第 块()区域的开垦耗时为 天。这 块区域可以同时开垦,所以总耗时 取决于耗时最长的区域&#xf…