supervisor 管理進程 基本用法

1. 咱們使用brew管理,先搜索一下確認是否有咱們須要的軟件包python

# davis @ XiaoWeis-MacBook-Pro in ~ [16:48:42]
$ brew search supervisor
==> Formulae
supervisor ✔                homebrew/linuxbrew-core/supervisor

  

2. 執行安裝linux

brew install supervisor

  

3. 啓動程序nginx

brew services start supervisor

  

4. ps 查看進程是否啓動成功git

# davis @ XiaoWeis-MacBook-Pro in ~ [16:56:33]
$ ps aux|grep supervisor
davis            12015   0.0  0.1  4309560   7560   ??  S     3:19PM   0:02.06 /usr/local/Cellar/supervisor/3.3.4/libexec/bin/python2.7 /usr/local/opt/supervisor/bin/supervisord -c /usr/local/etc/supervisord.ini --nodaemon
davis            16638   0.0  0.0  4268020    780 s000  S+    4:57PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn supervisor

  

5. supervisord.ini 配置api

/usr/local/etc/supervisord.ini

  配置文件末尾有一個載入配置的路徑python2.7

[include]
files = /usr/local/etc/supervisor.d/*.ini

  而後咱們新建一個supervisor.d目錄svn

mkdir supervisor.d

  而後咱們進入到這個目錄中,新建一個xxx.ini文件,就能夠寫咱們本身的配置了,就像nginx server目錄下同樣的道理rest

6.配置項,參數詳情:https://blog.51cto.com/lixcto/1539136code

[program:weatherApi]
directory = /Users/davis/python_prduction/weather
command = /usr/local/bin/python3.7 /Users/davis/python_prduction/weather/index.py
autostart = true
startsecs = 3
autorestart = true
startretries = 3
user = davis
redirect_stderr = true
stdout_logfile_backups = 20
stdout_logfile=/Users/davis/logs/weather_api_success.log
stdout_logfile_maxbytes=10MB

  而後保存退出,/usr/local/etc,退到這個路徑orm

# davis @ XiaoWeis-MacBook-Pro in /usr/local/etc [17:22:45]
$ supervisorctl -c supervisord.ini
autoUpdataWeatherData            STOPPED   May 15 05:06 PM
weatherApi                       STOPPED   May 15 05:06 PM
supervisor> reload
Really restart the remote supervisord process y/N? y
Restarted supervisord
supervisor>

  reload 重啓

  start weatherApi 啓動

  stop weatherApi 中止

相關文章
相關標籤/搜索