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 中止