最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】升级CentOS中的supervisor到最新版本

CentOS crifan 5671浏览 0评论

折腾:

【已解决】supervisor的supervisorctl start出错:unix:///var/run/supervisor/supervisor.sock no such file

期间,需要把服务器CentOS中supervisor的版本从3.1.4升级到最新版本3.3.4,或者是至少3.2.0版本之后,以便于支持environment环境变量。

其中需要注意的是:

升级后,要记得使用上现在的配置:

<code>cat /etc/supervisord.conf 
…
</code>

[include]

;files = supervisord.d/*.ini

files = /etc/supervisord.d/*.conf

以防万一,备份现有配置:

/etc/supervisord.conf

<code>; Sample supervisor config file.

[unix_http_server]
file=/var/run/supervisor/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef 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/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;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)
environment=ROBOTDEMO_PRJOECT_ROOT=/xxx/robotDemo,ROBOTDEMO_VIRTUALENV_ROOT=/root/.local/share/virtualenvs/robotDemo-dwdcgdaG

; 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/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 http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history ; use readline history if available

; The below sample program section 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)
;autorestart=true ; retstart at unexpected quit (default: true)
;startsecs=10 ; number of secs prog must stay running (def. 1)
;startretries=3 ; max # of serial start failures (default 3)
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;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 (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 (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 below sample eventlistener section shows all possible
; eventlistener subsection values, create one or more 'real'
; eventlistener: sections to be able to handle event notifications
; sent by supervisor.

;[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)
;autorestart=unexpected ; restart at unexpected quit (default: unexpected)
;startsecs=10 ; number of secs prog must stay running (def. 1)
;startretries=3 ; max # of serial start failures (default 3)
;exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;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 (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 ; # of stderr logfile backups (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 below sample group section 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 = supervisord.d/*.ini
files = /etc/supervisord.d/*.conf
</code>

Installing — Supervisor 3.3.4 documentation

不过最好先去看,之前自己是通过什么方式安装的supervisor

之前是

<code>yum install supervisord
</code>

详见:

【已解决】CentOS中用python2的pip去安装supervisor后找不到/etc/supervisor中的默认配置文件supervisord.conf

其中还:

<code>pip uninstall supervisor
pip2 uninstall supervisor
</code>

 再去用yum安装的

原因是之前,pip安装的supervisor的配置文件,不是默认的/etc/下面的,不利于使用

(不过注意到pip安装的supervisor是最新的3.3.4的版本

并且yum安装后,自带允许systemctl去管理supervisord

后来发现:

http://supervisord.org/installing.html

也提到了这点:

“Use the package management tools of your distribution to check availability; e.g. on Ubuntu you can run apt-cache show supervisor, and on CentOS you can run yum info supervisor.

A feature of distribution packages of Supervisor is that they will usually include integration into the service management infrastructure of the distribution, e.g. allowing supervisord to automatically start when the system boots.

Distribution packages of Supervisor can lag considerably behind the official Supervisor packages released to PyPI. For example, Ubuntu 12.04 (released April 2012) offered a package based on Supervisor 3.0a8 (released January 2010).”

现在yum安装后,不是最新版本

去看看现有的:

<code>[root@xx-general-01 robotDemo]# which supervisor
/usr/bin/which: no supervisor in (/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@xx-general-01 robotDemo]# which supervisord
/usr/bin/supervisord
[root@xx-general-01 robotDemo]# ll /usr/bin/supervisord 
-rwxr-xr-x 1 root root 318 Jul 29  2017 /usr/bin/supervisord
</code>

去找找,centos yum安装,能否指定版本

centos yum install supervisor version

Installing — Supervisor 3.3.4 documentation

<code>[root@xx-general-01 robotDemo]# yum info supervisor
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * nux-dextop: mirror.li.nux.ro
Installed Packages
Name        : supervisor
Arch        : noarch
Version     : 3.1.4
Release     : 1.el7
Size        : 2.2 M
Repo        : installed
From repo   : epel
Summary     : A System for Allowing the Control of Process State on UNIX
URL         : http://supervisord.org/
License     : ZPLv2.1 and BSD and MIT
Description : The supervisor is a client/server system that allows its users to control a
            : number of processes on UNIX-like operating systems.

</code>

此处镜像中只有3.1.4版本的supervisor

那估计用yum安装的话,很难再指定更高的版本了

Installing Supervisor and Superlance on CentOS

centos下安装supervisor – 简书

How To Upgrade Supervisord In CentOS 6 – LinuxAdmin.io

package management – How do I install Supervisor on CentOS? – Unix & Linux Stack Exchange

CentOS7下Supervisor安装与配置(Linux/Unix进程管理工具)_服务器应用_Linux公社-Linux系统门户网站

或许是:

用pip安装最新版,然后参考上面去手动加上:supervisor.service(或supervisord.service)

但是很麻烦啊

centos yum 指定版本

在CentOS系统中使用yum安装指定版本软件 – CSDN博客

<code>[root@xx-general-01 robotDemo]# yum list | grep supervisor
supervisor.noarch                        3.1.4-1.el7                  @epel     
nodejs-supervisor.noarch                 0.6.0-2.el7                  epel  
</code>

只有3.1.4版本的supervisor,没有其他版本,更谈不上指定安装更高版本的了

centos yum supervisor high version

Running Supervisor — Supervisor 3.3.4 documentation

Supervisor/initscripts: User-contributed OS init scripts for Supervisor

initscripts/centos-systemd-etcs at master · Supervisor/initscripts

估计是可以直接利用上面的脚步,实现开机自动启动,和用systemctl去管理supervisord的

python – How to automatically start supervisord on Linux (Ubuntu) – Server Fault

an init.d script for supervisord

此处好像是用的是sevrice管理的

所以就可以去试试:

  • 删除旧的用yum安装的supervisor

  • 用eash_install或pip去安装supervisor

    • 可以确保是最新版本3.3.4.或至少是3.2.0之后的版本了

  • 再去创建可以用systemctl管理supervisord的配置和文件

<code>[root@xx-general-01 robotDemo]# yum uninstall supervisor
Loaded plugins: fastestmirror
No such command: uninstall. Please use /usr/bin/yum --help
[root@xx-general-01 robotDemo]# yum remove supervisor
Loaded plugins: fastestmirror
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package supervisor.noarch 0:3.1.4-1.el7 will be erased
--&gt; Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================
 Package                                       Arch                                      Version                                           Repository                                Size
==========================================================================================================================================================================================
Removing:
 supervisor                                    noarch                                    3.1.4-1.el7                                       @epel                                    2.2 M

Transaction Summary
==========================================================================================================================================================================================
Remove  1 Package

Installed size: 2.2 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : supervisor-3.1.4-1.el7.noarch                                                                                                                                          1/1 
warning: /etc/supervisord.conf saved as /etc/supervisord.conf.rpmsave
  Verifying  : supervisor-3.1.4-1.el7.noarch                                                                                                                                          1/1 

Removed:
  supervisor.noarch 0:3.1.4-1.el7                                                                                                                                                         

Complete!
[root@xx-general-01 robotDemo]# 
</code>

后来注意到:

此处还残留之前的配置文件的:

<code>[root@xx-general-01 robotDemo]# ll /etc/supervisord.*
-rw-r--r-- 1 root root 8145 May 24 11:34 /etc/supervisord.conf.rpmsave

/etc/supervisord.d:
total 4
-rw-r--r-- 1 root root 2161 May 24 13:56 supervisord_server.conf
</code>

然后再去安装:

【已解决】CentOS中用pip或easy_install安装supervisor

然后再去:

【已解决】CentOS中如何用systemctl管理supervisor包括设置supervisor开机启动

即可。

转载请注明:在路上 » 【已解决】升级CentOS中的supervisor到最新版本

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
88 queries in 0.182 seconds, using 22.16MB memory