<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/post//</link>
<title><![CDATA[Supervisor安装与配置（Linux/Unix进程管理工具）]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[电脑技术]]></category>
<pubDate>Thu, 30 Sep 2021 03:52:53 +0000</pubDate> 
<guid>https://www.heckjj.com/post//</guid> 
<description>
<![CDATA[ 
	Supervisor（http://supervisord.org/）是用Python开发的一个client/server服务，是Linux/Unix系统下的一个进程管理工具，不支持Windows系统。它可以很方便的监听、启动、停止、重启一个或多个进程。用Supervisor管理的进程，当一个进程意外被杀死，supervisort监听到进程死后，会自动将它重新拉起，很方便的做到进程自动恢复的功能，不再需要自己写shell脚本来控制。<br/><br/>安装(pip安装)<br/>pip安装supervisord<br/><br/>pip install supervisor<br/>生成配置文件<br/><br/>echo_supervisord_conf > /etc/supervisord.conf<br/>载入配置文件<br/><br/>supervisorctl&nbsp;&nbsp;-c /etc/supervisord.conf <br/>常用命令<br/><br/>supervisorctl stop program_name&nbsp;&nbsp;# 停止某一个进程，program_name 为 [program:x] 里的 x<br/>supervisorctl start program_name&nbsp;&nbsp;# 启动某个进程<br/>supervisorctl restart program_name&nbsp;&nbsp;# 重启某个进程<br/>supervisorctl stop groupworker:&nbsp;&nbsp;# 结束所有属于名为 groupworker 这个分组的进程 (start，restart 同理)<br/>supervisorctl stop groupworker:name1&nbsp;&nbsp;# 结束 groupworker:name1 这个进程 (start，restart 同理)<br/>supervisorctl stop all&nbsp;&nbsp;# 停止全部进程，注：start、restartUnlinking stale socket /tmp/supervisor.sock<br/>、stop 都不会载入最新的配置文件<br/>supervisorctl reload&nbsp;&nbsp;# 载入最新的配置文件，停止原有进程并按新的配置启动、管理所有进程<br/>supervisorctl update&nbsp;&nbsp;# 根据最新的配置文件，启动新配置或有改动的进程，配置没有改动的进程不会受影响而重启<br/>安装(文件安装)<br/>wget https://pypi.python.org/packages/31/7e/788fc6566211e77c395ea272058eb71299c65cc5e55b6214d479c6c2ec9a/supervisor-3.3.3.tar.gz#md5=0fe86dfec4e5c5d98324d24c4cf944bd<br/> <br/>tar -zxvf supervisor-3.3.3.tar.gz<br/>cd supervisor-3.3.3<br/>python setup.py install<br/><br/><br/>supervisor安装完成后会生成三个执行程序：supervisortd、supervisorctl、echo_supervisord_conf，分别是supervisor的守护进程服务（用于接收进程管理命令）、客户端（用于和守护进程通信，发送管理进程的指令）、生成初始配置文件程序。<br/><br/>添加应用<br/>supervisord.conf 文件底部追加<br/><br/>[program:web]<br/>command=/usr/bin/python /Users/qp/web/app.py<br/>autostart=true <br/>autorestart=false <br/>stderr_logfile=/tmp/test_stderr.log <br/>stdout_logfile=/tmp/test_stdout.log <br/>问题<br/>遇到“Another program is already listening on a port that one of our HTTP servers is configured to use.”这个报错是因为 Supervisor已经启动了，这个时候如果想要解决这个问题，最简单的方法自然是 kill 掉进程，然后重启。<br/>$ ps aux &#124; grep supervisord<br/>qp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 95808&nbsp;&nbsp; 0.0&nbsp;&nbsp;0.0&nbsp;&nbsp;4286732&nbsp;&nbsp;&nbsp;&nbsp;744 s003&nbsp;&nbsp;S+&nbsp;&nbsp; 10:22上午&nbsp;&nbsp; 0:00.01 grep supervisord<br/>qp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 95600&nbsp;&nbsp; 0.0&nbsp;&nbsp;0.1&nbsp;&nbsp;4303732&nbsp;&nbsp; 7656&nbsp;&nbsp; ??&nbsp;&nbsp;Ss&nbsp;&nbsp; 10:12上午&nbsp;&nbsp; 0:00.20 /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python /usr/local/bin/supervisord -c /etc/supervisor.conf<br/>$kill 95808 95600<br/>http://127.0.0.1:9001 refused connection<br/>supervisor.conf 修改如下<br/><br/><br/>控制台输入supervisorctl，进入控制台时要输入的账号密码<br/>[inet_http_server]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; inet (TCP) server disabled by default<br/>port=127.0.0.1:9001&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; ip_address:port specifier, *:port for all iface<br/>username=user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;; default is no username (open server)<br/>password=123&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; default is no password (open server)<br/><br/>[supervisorctl]<br/>;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL&nbsp;&nbsp;for a unix socket<br/>serverurl=http://127.0.0.1:9001 <br/><br/><br/><br/>启动和停止服务示例如下<br/><br/>echo "$&#123;USER&#125;" `date '+%Y%m%d-%H%M%S'`>> restart-rcms.log<br/>supervisorctl stop rcms-auth<br/>supervisorctl stop rcms-system<br/>supervisorctl stop rcms-notice<br/>supervisorctl stop rcms-business<br/>supervisorctl stop rcms-workflow<br/>supervisorctl stop rcms-xxljob<br/>supervisorctl stop rcms-im<br/>supervisorctl stop rcms-gateway<br/><br/>supervisorctl start rcms-auth<br/>./wait-for-it.sh -t 120 localhost:19001<br/>supervisorctl start rcms-system<br/>supervisorctl start rcms-notice<br/>supervisorctl start rcms-business<br/>supervisorctl start rcms-workflow<br/>supervisorctl start rcms-xxljob<br/>supervisorctl start rcms-im<br/>supervisorctl start rcms-gateway<br/>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/post//#blogcomment</link>
<title><![CDATA[[评论] Supervisor安装与配置（Linux/Unix进程管理工具）]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>