raspbian下supervisor安装配置

1、安装

安装比较简单执行一下命令即可

sudo apt-get install supervisor
2、修改配置文件
/etc/supervisor/supervisord.conf

修改配置,通过web页面可查看进程工作状态。内容如下

; supervisor config file

[unix_http_server]
file=/var/run//supervisor.sock   ; (the path to the socket file)
;chmod=0700                       ; sockef file mode (default 0700)

[inet_http_server]         ; inet (TCP) server disabled by default
port=0.0.0.0:9001        ; (ip_address:port specifier, *:port for all iface)
username=user              ; (default is no username (open server))
password=123               ; (default is no password (open server))


[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

;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]
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 = /etc/supervisor/conf.d/*.conf
3、添加进程配置文件

安装轻型http服务器

pip3 install gunicorn
gunicorn -w 4 -b 0.0.0.0:8080 flaskgunicorn:app #flaskguicorn文件名 app应用名。

在/etc/supervisor/conf.d下添加 xxx.conf即可内容如下

[program:cameraService]
directory =/home/project/CameraServer/
command =gunicorn -w 4 -b 0.0.0.0:5000 index:app 
autostart = true     
startsecs = 5        
autorestart = true  
startretries = 10     
user = root          
redirect_stderr = true  
stdout_logfile_maxbytes = 20MB 
stdout_logfile_backups = 20    

stdout_logfile = /home/project/CameraServer/CameraServer.log

视频推流hls配置如下

[program:ffmpegvideo1]
directory =/home/project/CameraServer/static/video1/
command = bash -c 'sleep 20s && ffmpeg -rtsp_transport tcp -v info -i "rtsp://192.168.1.207:554/user=admin&password=&channel=1&stream=1.sdp?real_stream" -c:v copy -c:a copy -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 1 -hls_list_size 6 -hls_wrap 10 -start_number 1 /home/project/CameraServer/static/video1/index.m3u8'
autostart = true     
startsecs = 5        
autorestart = true   
startretries = 10     
user = root          
redirect_stderr = true  
stdout_logfile_maxbytes = 20MB  
stdout_logfile_backups = 20     

你可能感兴趣的:(raspbian下supervisor安装配置)