Centos7 守护进程supervisord 安装使用
pervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程,当一个进程意外被杀死,supervisort监听到进程死后,会自动将它重新拉起,很方便的做到进程自动恢复的功能,不再需要自己写shell脚本来控制。
1.获取supervisor包:【https://pypi.python.org/pypi/supervisor】
- wget https://pypi.python.org/packages/80/37/964c0d53cbd328796b1aeb7abea4c0f7b0e8c7197ea9b0b9967b7d004def/supervisor-3.3.1.tar.gz
2.解压supervisor-3.3.1.tar.gz
- tar zxvf supervisor-3.3.1.tar.gz && cd supervisor-3.3.1
3.安装
- python setup.py install
报错如下:
【解决办法】:没有setuptools的模块,说明python缺少这个模块,那我们只要安装这个模块即可解决此问题
- wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
python setup.py install
4.创建supervisor的配置文件
- echo_supervisord_conf > /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/supervisor/conf.d/*.ini
4.1配置管理进程
- [program:FirstCentos]
- command=dotnet FirstCentos.dll
- directory=/home/www/fc
- environment=ASPNETCORE__ENVIRONMENT=Production
- user=root
- stopsignal=INT
- autostart=true
- autorestart=true
- startsecs=3
- stderr_logfile=/var/log/FirstCentos.err.log
- stdout_logfile=/var/log/FirstCentos.out.log
详细请参考:https://www.cnblogs.com/wangmo/p/8882072.html
5.开启supervisor服务
- supervisord -c /etc/supervisord.conf
6.守护的进程管理
7.启用supervisor web管理界面
出于安全考虑,默认配置是没有开启web管理界面,需要修改supervisord.conf配置文件打开http访权限,将下面的配置
修改文件 /etc/supervisord.conf
将
改成:
防火墙开启端口:9001
8.开机启动
参考:
https://blog.csdn.net/donggege214/article/details/80264811
https://www.cnblogs.com/justphp/p/6120201.html
https://www.cnblogs.com/wangmo/p/8882072.html
https://blog.csdn.net/xyang81/article/details/51555473
Centos7 守护进程supervisord 安装使用的更多相关文章
- centos7 守护进程
ASP.NET Core应用程序发布linux在shell中运行是正常的.可一但shell关闭网站也就关闭了,所以要配置守护进程, 用的是Supervisor,本文主要记录配置的过程和过程遇到的问题 ...
- [视频教程] ubuntu系统下以守护进程方式安装使用Redis
直接访问redis的中国官网,在下载部分,可以看到安装和使用的方式.wget http://download.redis.io/releases/redis-5.0.4.tar.gztar xzf r ...
- centos安装守护进程工具supervisor
安装命令 yum install supervisor 启动守护进程 supervisord -c /etc/supervisord.conf 切换至/etc/supervisord.d目录下 写一个 ...
- docker 学习笔记20:docker守护进程的配置与启动
安装好docker后,需要启动docker守护进程.有多种启动方式. 一.服务的方式 因为docker守护进程被安装成服务.所以,可以通过服务的方式启停docker守护进程,包括查看状态. sudo ...
- CentOS7 安装supervisor守护进程管理器
supervisor没有发布在标准的CentOS源在,需要安装epel源.这种方式安装的可能不是最新版本,但比较方便,安装完成之后,配置文件会自动帮你生成. 默认配置文件:/etc/superviso ...
- Ubuntu安装守护进程supervisor
Supervisor安装与配置(Linux/Unix进程管理工具) asp.net core 负载均衡集群搭建(centos7+nginx+supervisor+kestrel) 为了保证服务能够稳定 ...
- Centos7 使用 Supervisor 守护进程 Celery
一.Supervisor 安装(centos7 还有另一个进程守护命令 Systemd ) Centos 7 安装 Supervisord 二.Supervisor 守护进程 Centos7 使用 S ...
- asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二)
原文:asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二) 续上一篇文章:asp.net core2.0 部署centos7/linux系统 -- ...
- supervisord守护进程的使用
原文链接:http://blog.csdn.net/xyang81/article/details/51555473 Supervisor(http://supervisord.org/)是用Pyth ...
随机推荐
- Spring Security 解析(七) —— Spring Security Oauth2 源码解析
Spring Security 解析(七) -- Spring Security Oauth2 源码解析 在学习Spring Cloud 时,遇到了授权服务oauth 相关内容时,总是一知半解,因 ...
- python数据分析三剑客之: pandas操作
pandas的操作 pandas的拼接操作 # pandas的拼接操作 级联 pd.concat , pd.append 合并 pd.merge , pd.join 一丶pd.concat()级联 # ...
- ssh工具推荐
FinalShell 看图就知道功能多强大了, 官网地址 http://www.hostbuf.com
- 你可能还不知道的关于JavaScript类型的细节?
类型 七种类型: Undefined Null Boolean String Number Symbol Object Undefined.Null 阅读问题:为什么有的编程规范要求使用void 0 ...
- vue项目使用html5+ barcode扫码在苹果遇到的问题以及自己的解决方法
之前在记录扫码 在安卓时,会出现黑屏,错位,闪退等等问题.解决方法在另一篇文章里 https://www.cnblogs.com/huzhuhua/p/11064764.html . 当时以为 是 ...
- JavaScript 之 location 对象
一.location 对象 location 对象是 window 对象下的一个属性,使用的时候可以省略 window 对象. 常用属性: location.href = 'http://www.ba ...
- idea2018破解
准备:ideaIU-2018.1.4.exe 安装程序 JetbrainsCrack-2.10-release-enc.jar 破解jar包 第一步:打开安装目录/bin,找到idea.exe.vmo ...
- echart绘制GDP数据
{% extends "base.html" %} {% block self_head_css_js %} {% endblock %} {% block main_conten ...
- 【漏洞复现】Apache Solr via Velocity template远程代码执行
0x01 概述 Solr简介 Apache Solr 是一个开源的企业级搜索服务器.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache Solr ...
- Win10如何设置插入鼠标后自动禁用触摸板
首先按“Windows+R”键,调出运行窗口. 然后输入“control”然后点击“确定”! 打开Win10控制面板 在“控制面板”中,选择“硬件和声音”! 选择“AUSU Amart Ges ...