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 ...
随机推荐
- OpenFaceswap 入门教程(3): 软件参数篇!
OpenFaceswap 的使用可以说是非常简单,只要稍加点拨就可以学会,厉害一点的人根本不需要教程,直接自己点几下就知道了.看了前面安装篇和使用篇.我想大多数人应该会了. 当学会了使用之后,你可能对 ...
- 网络编程协议(TCP和UDP协议,粘包问题)以及socketserver模块
网络编程协议 1.osi七层模型 应用层 表示层 会话层 传输层 网络层 数据链路层 物理层 2.套接字 socket 有两类,一种基于文件类型,一种基于网络类型 3.Tcp和udp协议 ...
- Codeforces Round #524 (Div. 2) C. Masha and two friends 思路
题目:题目链接 思路:直接计数显然是不好处理的,但分情况讨论只要不写错这题是一定可以出的,但这样基本做完这个题就没时间做其他题了,但当时我就这么蠢的这样做了,比赛一个半小时的时候突然发现一个似乎可行的 ...
- MySQL基础3-SQL语言
1.DQL语句分类 重点在于Select语句 2.Sql语句的书写规则 3.怎样使用Navicat导入已经写好的sql文件 (1)在Navicat中右击选中的数据库 (2)将sql文件所在的路径添加进 ...
- Django admin模块使用search时报错:django.core.exceptions.FieldError: Related Field got invalid lookup: contains
日志如下: <class 'django.core.handlers.wsgi.WSGIRequest'> ------------registered_admins: {'spaceCl ...
- 【SCOI 2010】传送带
为了方便,我们不妨设$\rm P \lt Q,R$ 我们发现,有$\rm E$点在$\rm AB$上,$\rm F$点在$\rm CD$上,最优解一定是$\rm AE\rightarrow EF\ri ...
- Python+Selenium基础篇之2-打开和关闭火狐浏览器
本节介绍如何初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打开fiefox浏览器.首先需要去下载一个driver插件geckodriver. ...
- 课堂笔记II
- random.nextInt方法用法
1.不带参数的nextInt()会生成所有有效的整数(包含正数,负数,0) 2.带参的nextInt(int x)则会生成一个范围在0~x(不包含X)内的任意正整数 例如:int x=new Rand ...
- Unity属性——AddComponentMenu
字面理解:添加 组件选项菜单 分析:可能是添加一个脚本或者组件到一个物体上 验证: 新建一个脚本:AttributeTest 提示:添加一个组件菜单属性,允许你放一个脚本在Compoent菜单下,来代 ...