利用setuptools的entry_point参数实现模块动态导入
gettext国际化用法示例

supervisor用法

妙音 posted @ 2015年7月09日 18:12 in python , 2528 阅读
以什么方式运行进程?将它做成服务,再以"service xxx start/stop"方式运行。
或者以"nohup xxx &"方式运行,需要停止时,先ps获得进程id,然后kill掉.
有什么好点的办法?supervisor正好解决这个问题。
  • 安装
sudo pip install supervisor
  • 创建配置文件
echo_supervisord_conf > /etc/supervisord.conf
  • 取消注释
打开/etc/supervisord.conf,取消下面两行注释,并修改files内容.
[include]
files = /etc/supervisor/*.ini
  • 新建配置目录
新建supervisor目录及test.ini文件
➜  /etc  tree supervisor
supervisor
└── test.ini
  • 配置内容
test.init内容
[program:test]
command=python -m SimpleHTTPServer 8000
directory=/home/wyq/
  • 运行
运行后,在浏览器访问8000端口
supervisord 
 
调试运行,此时需要先将test.ini中directory注释掉.
supervisord -d
supervisor也可指定配置文件
 
supervisord -c xxxx
  • 查看日志
tail -f supervisord.conf
  • 查看运行状态
➜  ~  supervisorctl status
test                             RUNNING   pid 4922, uptime 0:00:07
  • 停止任务
启动与重启参数为start/restart
 
➜  ~  supervisorctl stop test
test: stopped
➜  ~  supervisorctl status   
test                             STOPPED   Jul 09 04:32 PM
  • 停止
supervisorctl shutdown
 
Avatar_small
dumpsters to rent ge 说:
2020年12月16日 23:41

I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. <a href="https://www.gojbar.com/georgetown">dumpsters to rent georgetown</a>

Avatar_small
Robinjack 说:
2020年12月23日 17:32

An intriguing discussion may be valued at comment. I do think you should write regarding this topic, may well certainly be a taboo subject but usually individuals are too few to speak on such topics. Yet another. Cheers delaware county transportation


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter