一、先介绍一下supervisor

  1.安装supervisor

    使用yum安装或者使用pip安装都可以,使用yum安装的相对简单一些,并且不用拷贝一份 supervisord.conf 的配置文件,在这里介绍一下pip安装的方式吧,我是后编译了一个python,执行下面一系列的命令:

/usr/local/python/bin/pip3 install supervisor
ln -s /usr/local/python/bin/supervisorctl /usr/bin/
ln -s /usr/local/python/bin/supervisord /usr/bin/
mkdir /etc/supervisor

  然后需要在这个文件中写入如下,都是固定的,直接拷贝即可:

vim /etc/supervisor/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 [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 ; 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 ; 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 = conf.d/*.conf

  其中主要是红色,随后进行:

mkdir /etc/supervisor/conf.d
cd /etc/supervisor/conf.d

  之后就要编辑要监管的服务了,编辑写入:

vim /etc/supervisor/conf.d/devpi.conf

[program:devpi]
command=/usr/local/python/bin/devpi-server --port 3141 --host 10.213.X.X --serverdir /home/ops/devpi
directory=/home/ops/devpi
autostart=true
autorestart=true
startretries=3
user=root
stopasgroup=true
killasgroup=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /var/log/devpi-running.log

  真正的模板对应改文件如下,并含解释:

[program:DeployLinux]   #DeployLinux  为程序的名称
command=dotnet DeployLinux.dll #需要执行的命令
directory=/home/publish #命令执行的目录
environment=ASPNETCORE__ENVIRONMENT=Production #环境变量
user=root #用户
stopsignal=INT
autostart=true #是否自启动
autorestart=true #是否自动重启
startsecs=3 #自动重启时间间隔(s)
stderr_logfile=/var/log/ossoffical.err.log #错误日志文件
stdout_logfile=/var/log/ossoffical.out.log #输出日志文件

  随后启动服务,即可:

supervisord -c /etc/supervisor/supervisord.conf

  查看状态,以及重新启动命令如下:

supervisorctl status
supervisorctl restart devpi

  这一部分的内容大概就是这些,参考文章:https://www.cnblogs.com/wyt007/p/8288929.html

  下面是devpi-server的相关内容:

  二、安装devpi-server

    这里同样是使用pip方式进行的安装,执行 pip install 该服务即可,安装成功后,可以使用如下命令查看版本:

/usr/local/python/bin/devpi-server --version

  还需要安装其他几个相关包:

/usr/local/python/bin/pip3 install -q -U devpi-web
/usr/local/python/bin/pip3 install -q -U devpi-client

  然后需要重新启动一下devpi,执行:

/usr/local/python/bin/devpi-server  --port 3141 --host 10.213.X.X --serverdir /home/ops/devpi --init

  这里我创建了一个devops的用户:

/usr/local/python/bin/devpi user -c devops password=devops
/usr/local/python/bin/devpi login devops --password=devops
/usr/local/python/bin/devpi index -c devops bases=root/pypi
/usr/local/python/bin/devpi use devops/devops
/usr/local/python/bin/devpi index devops/devops mirror_url="https://pypi.doubanio.com/simple"

  在我的 ~/.pip/pip.conf 中的为:

[global]
index-url = https://pypi.doubanio.com/simple [search]
index = https://pypi.doubanio.com/simple [install]
trusted-host = 10.213.X.X #就是我的devpi的服务器

  随后可以使用下面两个命令进行查看:

devpi use
devpi index
devpi index root/pypi mirror_url="https://pypi.doubanio.com/simple" 具体的记不太清楚了

  下面进行测试看一看:

devpi login devops
devpi use
cd /tmp/filelock-3.0.10/ # 要上传的包目录下
devpi upload # 上传到devops索引下
devpi list filelock # 查看索引

  

这里有一篇参考文章,如:https://www.cnblogs.com/panhongyin/p/7065830.html

Centos7 中使用搭建devpi并且使用Supervisor守护进程的更多相关文章

  1. 【Centos7】 中使用Supervisor守护进程

    原文出处: Centos7 中使用Supervisor守护进程 配置supervisor实现进程守护 1.安装supervisor yum install Supervisor   2.启动服务 su ...

  2. Centos7 使用 Supervisor 守护进程 Celery

    一.Supervisor 安装(centos7 还有另一个进程守护命令 Systemd ) Centos 7 安装 Supervisord 二.Supervisor 守护进程 Centos7 使用 S ...

  3. 【转载】Centos7 中使用Supervisor守护进程

    配置supervisor实现进程守护 1.安装supervisor yum install Supervisor   2.启动服务 supervisord -c /etc/supervisord.co ...

  4. Centos7 中使用Supervisor守护进程

    转:https://www.cnblogs.com/qmhuang/p/8196132.html 配置supervisor实现进程守护 1.安装supervisor yum install Super ...

  5. CentOS7 安装supervisor守护进程管理器

    supervisor没有发布在标准的CentOS源在,需要安装epel源.这种方式安装的可能不是最新版本,但比较方便,安装完成之后,配置文件会自动帮你生成. 默认配置文件:/etc/superviso ...

  6. Linux Supervisor 守护进程基本配置

    supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控.管理进程.常用于管理与某个用户或项目相关的进程. 组成部分supervisord:服务守护进程supervisorctl ...

  7. centos 下Supervisor 守护进程基本配置

    supervisor:C/S架构的进程控制系统,可使用户在类UNIX系统中监控.管理进程.常用于管理与某个用户或项目相关的进程. 组成部分supervisord:服务守护进程supervisorctl ...

  8. DUBBO+Zookeeper在Centos7中本地搭建及小案例

    环境: 1.centos7 2.jdk-7u76-linux-x64.tar.gz 2.tomcat:apache-tomcat-7.0.59.tar.gz 3.zookeeper-3.4.6.tar ...

  9. centos7 .net core 使用supervisor守护进程,可以后台运行

    1.安装supervisor yum install supervisor 2.配置supervisor vi /etc/supervisord.conf 拉到最后,这里的意思是 /etc/super ...

随机推荐

  1. https 理解

    这张图已经很明白,以下为翻译: 一.秘钥传输过程(确认秘钥相同) 1.请求服务端 2.服务端有公司要 3.公钥发给客户端 4.验证发过来的公钥crt,生成随机秘钥,并用此公钥加密 5.加密后的秘钥发给 ...

  2. Linux实战教学笔记41:企业级SVN版本管理与大型代码上线方案

    第1章 SVN服务实战应用指南 1.1 SVN介绍 1.1.1 什么是SVN(Subversion)? Svn(subversion)是近年来崛起的非常优秀的版本管理工具,与CVS管理工具一样,SVN ...

  3. java算法 第七届 蓝桥杯B组(题+答案) 9.取球博弈

    9.取球博弈  (程序设计) 两个人玩取球的游戏.一共有N个球,每人轮流取球,每次可取集合{n1,n2,n3}中的任何一个数目.如果无法继续取球,则游戏结束.此时,持有奇数个球的一方获胜.如果两人都是 ...

  4. go_函数

    函数语法要点 返回值类型写在最后面 可返回多个值 函数可作为参数 没有默认参数,可选参数,只有可变参数列表(...int) package main import ( "fmt" ...

  5. len=in.read(b,0,len)和len=in.read(b)的区别

    byte[] byte = new byte[1024]; int len =0 ; while((len=in.read(b))!=-1){ out.write(b,0,len); } read函数 ...

  6. 刷题向》关于一道尺取法的神题目(BZOJ4653)(HARD-)(BZOJ 30题纪念)

    不得不说,这也许会是一道长期在我的博客里作为“HARD”难度存在的题 这道题能很好的考验选手的思考能力,但本蒟蒻最后还是听了省队爷讲了之后才会...(默默面壁) 题目里,说对于每一个点,是用当前选出的 ...

  7. Library not found for -lAPOpenSdk

    多人开发合作的时候 总是会遇见各种各样的问题 今天就来讲一个关于友盟的问题 在我的小伙伴 用cocoapods 中添加了这样一句话 pod ‘UMengSocialCOM’,  并且pod updat ...

  8. TF录像存储专项测试

    测试环境 移动设备:小米4C 移动设备版本:Android 5.1 IPC版本号:0.1.4110_10.1.1.1.3948 安居小宝版本:Version:2.0.1 测试网络:IPC使用WIFI网 ...

  9. 修改字段注释modify

    alter table test1 modify 字段名 类型 comment '修改后的字段注释'; ALTER TABLE tc_activity_miaosha MODIFY `validity ...

  10. Ubuntu的SWAP设置

    1. 在Ubuntu中配置使用新创建的Swap分区 Command list: 查找Swap分区的UUID sudo blkid 在/ect/fstab中加入新的Swap分区 sudo gedit / ...