Linux:supervisor命令的使用
supervisor是Linux下一个便利的启动和监控服务的命令。
典型的supervisor.conf配置如下:(配置文件的注释用分号开头)
; supervisor config file
[unix_http_server] ; supervisor与supervisorctl的通讯
file=/var/run/supervisor.sock ; (the path to the socket file) should match serverurl in section supervisorctl
chmod=0700 ; sockef file mode (default 0700) [supervisord] ; 必须有,用来配置supervisord
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) ; 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] ; 必须有,用于配置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 = /path/to/*.conf # other configuration files you want to include [program:api4c] ;应用程序的配置
command=/path/to/python/env/bin/gunicorn -w 1 -b 0.0.0.0:8888 wsgi:application ; 执行你的命令,不能是用于启动守护进程,因为supervisor就是用来作为守护进程的
directory=/home/ubuntu/4c-entry/api4c ; chdir to here before command run
startsecs=0 ;
stopwaitsecs=0 ;
autostart=true ; supervisord启动的时候自动运行
autorestart=true ; 当程序中断的时候是否重启 stop,true,false,unexpected
stdout_logfile=/path/to/logfile.log ; 必须已经存在
stderr_logfile=/path/to/std/err/log/for4c.err
supervisor的常用命令:
supervisorctl -c supervisor.conf status 察看supervisor的状态
supervisorctl -c supervisor.conf reload 重新载入 配置文件 更新后可以选择重新载入
supervisorctl -c supervisor.conf start [all] | [appname] 启动指定/所有 supervisor管理的程序进程
supervisorctl -c supervisor.conf stop [all] | [appname]
命令使用实例:
来源: http://chenxiaoyu.org/2011/05/31/python-supervisor.html
配置项:
[program:hello]
command=python /home/smallfish/hello.py
autorstart=true
stdout_logfile=/home/smallfish/hello.log
命令
shell> sudo /etc/init.d/supervisor start -- 启动supervisor服务
shell> sudo supervisorctl status hello -- 获取hello服务的状态,因为是autorstart,这里已经启动了 hello RUNNING pid 1159, uptime 0:20:32
shell> sudo supervisorctl stop hello -- 停止hello服务 hello: stopped
shell> sudo supervisorctl stop hello -- 再次停止hello,会有错误信息 hello: ERROR (not running)
shell> sudo supervisorctl start hello -- 启动hello服务 hello: started
常用的配置项:
Linux:supervisor命令的使用的更多相关文章
- Linux Supervisor的安装与使用入门---SuSE
Linux Supervisor的安装与使用入门 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事 ...
- Linux Supervisor的安装与使用入门---Ubuntun
Linux Supervisor的安装与使用入门 在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事 ...
- linux 常用命令。
/* Linux常用命令? 1 查看 ls 展示当前目录下的可见文件 ls -a 展示当前目录下所有的文件(包括隐藏的文件) ls -l(ll) ...
- linux grep命令
linux grep命令1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressio ...
- Linux常用命令(一)
Linux常用命令 1. pwd查看当前路径(Print Working Directory) [root@CentOS ~]# pwd/root 2. cd .. 返回上一级 .. 表示上一级 ...
- Linux下命令行安装weblogic10.3.6
Linux下命令行安装weblogic10.3.6 一.安装前准备工作: 1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中 ...
- Linux paste命令
Linux paste命令用于合并文件的列. paste指令会把每个文件以列对列的方式,一列列地加以合并. 语法 paste [-s][-d <间隔字符>][--help][--versi ...
- 20145222《信息安全系统设计基础》Linux常用命令汇总
学习Linux时常用命令汇总 通过Ctrl+f键可在该网页搜索到你想要的命令. Linux中命令格式为:command [options] [arguments] //中括号代表是可选的,即有些命令不 ...
- Linux sudo 命令的应用
.note-content { font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeit ...
- linux 基础命令与文件管理
Linux终端介绍 Shell提示符 Bash Shell基本语法 基本命令的使用:ls.pwd.cd 查看系统和BIOS硬件时间 Linux如何获得帮助 Linux关机命令:shutdow.in ...
随机推荐
- 读书笔记-JavaScript面向对象编程(二)
第5章 原型 5.1 原型属性(所有函数拥有一个prototype属性,默认为空对象) 5.1.1 利用原型添加方法和属性 function Gadget(name,color){ this.name ...
- BFS:CF356C-Compartments
C. Compartments time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- BZOJ 4393: [Usaco2015 Dec]Fruit Feast
DP #include<cstdio> using namespace std; int T,A,B,F[5000005],G[5000005]; int main(){ scanf(&q ...
- 免费生成https证书以及配置
http升级到https需要在nginx的配置中加入证书信息,查询资料后确定生成证书两种方案 第一种:自签名证书,然后开启 CloudFlare 的 CDN 服务 //确定是否安装openss ...
- 使用dnspod遭遇的奇特问题以及背后的原因与临时解决方法
由于园子里有不少用户在使用dnspod,我们觉得有必要将这两天blogjava.net域名在dsnpod遇到的奇特问题分享一下,以免再有人踩着这个坑. 12月11日,我们登录到dnspod的后台时,大 ...
- Python+selenium(警告框处理)
在Webdriver中处理JavaScript生成的alert.confirm.prompt,使用switch_to_alert()方法定位到alert.confirm.prompt,然后进行如下操作 ...
- day02_01.能被3整除的数
第1题 能被3整除的数 编程思想的初步形成 把人的正常思维放大化,用放大镜去放大你的每个思考过程 你会发现,原来编程没有你想象的那么难 题目:输出100以内(不含100)能被3整除的所有整数 < ...
- PAT——乙级1001and1011
准备明年年初考PAT,练题呀,暂且先把LeetCode放下. 我是按照算法笔记这个教材刷的. B1001 1001 害死人不偿命的(3n+1)猜想 (15 point(s)) 卡拉兹(Callatz) ...
- Windows 7中安装SQL2005提示IIS未安装 解决办法 .(转载)
在Windows 7系统中安装SQL Server 2005时,可能会收到一个警告:提示IIS未安装或者未启用.在通过“控制面板”的“打开或关闭Windows功能”按默认设置安装IIS后,发现仍有这个 ...
- RESTful-rest_framework认证组件、权限组件、频率组件-第五篇
认证组件.权限组件.频率组件总结: 认证组件格式: 1 写一个认证类 from rest_framework.authentication import BaseAuthentication cla ...