Supervisor-进程管理入门
2016-07-02 15:10
507 查看
实践出真知,做个简单的实验,系统为Ubuntu14.04
这样就生成了一个原始的配置文件,但是有些需要改动下才好使
sudo vim /etc/supervisord.conf
这里要注意 unix_http_server 跟 supervisorctl中的 sock 文件目录要一致
然后创建目录
sudo su - root -c “mkdir -p /etc/supervisord.d”
之后进程管理的脚本放到supervisord.d就行了
配置一个进程管理脚本 放在 /etc/supervisord.d 目录下
somejob.ini
操作
supervisord 启动
看到我的job进程已经启动了,检查日志文件, 也已经正常
supervisord 重载
进程查看
进程重载 修改下job 程序,看看效果
查看日志
进程关闭
查看进程
还有一部分是web界面的对进程的管理,还有开机启动等,这些可以自行查看文档 或者 google
Herd UNIX processes with Supervisor
声明:
本文出自 “orangleliu笔记本” 博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/45057377
作者orangleliu 采用署名-非商业性使用-相同方式共享协议
快速安装配置
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> pip_python install supervisor <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">echo</span>_supervisord_conf > /etc/supervisord.conf <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 会报错 permission denied: /etc/supervisord.conf,可以使用下面的语句</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> su - root -c <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"echo_supervisord_conf > /etc/supervisord.conf"</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>
这样就生成了一个原始的配置文件,但是有些需要改动下才好使
sudo vim /etc/supervisord.conf
<code class="hljs r has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span> [unix_http_server] file=/var/run/supervisor.sock ; (the path to the socket file) <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span> [supervisord] logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span> [supervisorctl] serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> a unix socket <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">...</span> [include] files = /etc/supervisord.d/*.ini</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li></ul>
这里要注意 unix_http_server 跟 supervisorctl中的 sock 文件目录要一致
然后创建目录
sudo su - root -c “mkdir -p /etc/supervisord.d”
之后进程管理的脚本放到supervisord.d就行了
下面就用一个简单的例子来说明
先写一个测试用的脚本<code class="language-python hljs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#!/usr/bin/python</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#-*- coding:utf-8 -*-</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">############################</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#File Name: somejob.py</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#Author: orangleliu</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#Mail: orangleliu@gmail.com</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#Created Time: 2015-04-15 11:08:13</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#License: MIT</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">############################</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">import</span> sys, time <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">while</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">True</span>: <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">print</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"pyserver runing %s"</span>%time.ctime() sys.stdout.flush() time.sleep(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li></ul>
配置一个进程管理脚本 放在 /etc/supervisord.d 目录下
somejob.ini
<code class="hljs ini has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 102, 102);">[program:somejob]</span> <span class="hljs-setting" style="box-sizing: border-box;">command=<span class="hljs-value" style="box-sizing: border-box;">/usr/bin/python /home/lzz/temp/super/somejob.py</span></span> <span class="hljs-setting" style="box-sizing: border-box;">directroy=<span class="hljs-value" style="box-sizing: border-box;">/home/lzz/temp/super/</span></span> <span class="hljs-setting" style="box-sizing: border-box;">autostart=<span class="hljs-value" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">true</span></span></span> <span class="hljs-setting" style="box-sizing: border-box;">autorestart=<span class="hljs-value" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">true</span></span></span> <span class="hljs-setting" style="box-sizing: border-box;">startretries=<span class="hljs-value" style="box-sizing: border-box;"><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span></span></span> <span class="hljs-setting" style="box-sizing: border-box;">user=<span class="hljs-value" style="box-sizing: border-box;">lzz</span></span> <span class="hljs-setting" style="box-sizing: border-box;">stdout_logfile=<span class="hljs-value" style="box-sizing: border-box;">/home/lzz/temp/super/%(program_name)s.log</span></span> <span class="hljs-setting" style="box-sizing: border-box;">stderr_logfile=<span class="hljs-value" style="box-sizing: border-box;">/home/lzz/temp/super/%(program_name)s.log</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li></ul>
操作
supervisord 启动
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">sudo /usr/local/bin/supervisord -c /etc/supervisord.conf lzz<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@ubuntu</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:supervisord</span>.d<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>ps -ef|grep <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">super</span> root <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5709</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30</span> ? <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span> /usr/bin/python /usr/local/bin/supervisord -c /etc/supervisord.conf lzz <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5710</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5709</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">30</span> ? <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span> /usr/bin/python /home/lzz/temp/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">super</span>/somejob.py</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
看到我的job进程已经启动了,检查日志文件, 也已经正常
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">lzz<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@ubuntu</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:super</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>tail somejob.log pyserver runing <span class="hljs-constant" style="box-sizing: border-box;">Wed</span> <span class="hljs-constant" style="box-sizing: border-box;">Apr</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">31</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">47</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span> pyserver runing <span class="hljs-constant" style="box-sizing: border-box;">Wed</span> <span class="hljs-constant" style="box-sizing: border-box;">Apr</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">31</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">57</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span> pyserver runing <span class="hljs-constant" style="box-sizing: border-box;">Wed</span> <span class="hljs-constant" style="box-sizing: border-box;">Apr</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">32</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">07</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2015</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
supervisord 重载
<code class="hljs sql has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">supervisorctl reread supervisorctl <span class="hljs-operator" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">update</span></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
进程查看
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">lzz<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@ubuntu</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:super</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>sudo supervisorctl somejob <span class="hljs-constant" style="box-sizing: border-box;">RUNNING</span> pid <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6021</span>, uptime <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
进程重载 修改下job 程序,看看效果
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> supervisorctl reload somejob</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
查看日志
<code class="hljs css has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">pyserver</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">runing</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Wed</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Apr</span> 15 11<span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:44</span><span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:22</span> 2015 <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">hi</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">pyserver</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">runing</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Wed</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Apr</span> 15 11<span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:44</span><span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:32</span> 2015 <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">hi</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">pyserver</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">runing</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Wed</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Apr</span> 15 11<span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:44</span><span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:38</span> 2015 <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">pyserver</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">runing</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Wed</span> <span class="hljs-tag" style="color: rgb(0, 0, 0); box-sizing: border-box;">Apr</span> 15 11<span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:44</span><span class="hljs-pseudo" style="color: rgb(0, 0, 0); box-sizing: border-box;">:48</span> 2015</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>
进程关闭
<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> supervisorctl stop somejob <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#启动这里改为start</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
查看进程
<code class="hljs ruby has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">lzz<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@ubuntu</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:super</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>ps -ef|grep <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">super</span> root <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6020</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">41</span> ? <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">00</span> /usr/bin/python /usr/local/bin/supervisord -c /etc/supervisord.conf</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
还有一部分是web界面的对进程的管理,还有开机启动等,这些可以自行查看文档 或者 google
参考:
スーパーサーバーSupervisorの導入手順メモHerd UNIX processes with Supervisor
声明:
本文出自 “orangleliu笔记本” 博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/45057377
作者orangleliu 采用署名-非商业性使用-相同方式共享协议
相关文章推荐
- MySQL和Tomcat8免安装版本的配置
- 《谷歌是如何运营的》读书笔记
- CSS 之 Position定位
- Hadoop安装
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- iOS—PageViewController循环切换界面问题
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 实时监听输入框值变化的完美方案:oninput & onpropertychange
- 用Qt做的两个简单的测试台程序