This commit is contained in:
xyj 2023-12-01 13:51:47 +08:00
parent ef1116dff2
commit 94f44d3300
9 changed files with 46 additions and 16 deletions

10
MQTT.py
View File

@ -18,16 +18,16 @@ def on_connect(client, userdata, flags, rc):
def on_message(client, userdata, msg):
data = json.loads(msg.payload.decode('utf-8'))["msg"]
if data == "push_stream":
# TODO 启动推流视频
# 启动推流视频
push_stream()
elif data == "close_stream":
# TODO 关闭推流视频
# 关闭推流视频
close_stream()
elif data == "exec":
# TODO 执行命令 更新配置
# 执行命令
exec_sh()
elif data == "update":
# TODO git更新项目
# git更新项目和配置文件
update()
else:
client.publish('conn_error', payload='No Such Type', qos=0)
@ -40,6 +40,6 @@ if __name__ == '__main__':
client.on_connect = on_connect
client.on_message = on_message
# Establish a connection
client.connect('ceshi-mqtt.lihaink.cn', 1883)
client.connect('127.0.0.1', 1883)
# Publish a message
client.loop_forever()

View File

@ -1,6 +1,6 @@
[program:mqtt]
directory=/home/lihai/PycharmProjects/pythonProject/lot_manager
command=/home/lihai/anaconda3/envs/chatchat/bin/python MQTT.py
directory=/home/lihai//PycharmProjects/pythonProject/lot_manager
command=/home/lihai//anaconda3/envs/chatchat/bin/python MQTT.py
user=lihai
autostart=true
autorestart=true

13
conf/test.conf Executable file
View File

@ -0,0 +1,13 @@
[program:test]
directory=/home/lihai/PycharmProjects/pythonProject/lot_manager
command=/home/lihai/anaconda3/envs/chatchat/bin/python test.py
user=lihai
;是否随开机自启 或者reload自启动
autostart=false
;失败重启
autorestart=true
;重启次数
restart_times=3
redirect_stderr=true
stopsignal=TERM
stopasgroup=True

10
conf/test2.conf Executable file
View File

@ -0,0 +1,10 @@
[program:test2]
directory=/home/lihai/PycharmProjects/pythonProject/lot_manager
command=/home/lihai/anaconda3/envs/chatchat/bin/python test.py
user=lihai
autostart=false
autorestart=true
restart_times=3
redirect_stderr=true
stopsignal=TERM
stopasgroup=True

View File

@ -1,6 +1,6 @@
[program:push_stream]
directory=/home/lihai/PycharmProjects/pythonProject/lot_manager
command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v copy -c:a aac -preset ultrafast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rstp://47.108.186.87:554/live/test9
command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v copy -c:a aac -preset ultrafast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rstp://127.0.0.1:554/live/test
user=lihai
autostart=true
autorestart=true

View File

@ -1,7 +1,6 @@
#!/bin/bash
#复制配置文件
cp -r conf/*.conf /etc/supervisor/conf.d/
set -e
cp -r reload_conf/*.conf /etc/supervisor/conf.d/
# 重启所有配置
supervisorctl reload
# 推流不启动
supervisorctl stop push_stream

View File

@ -1,2 +1,4 @@
#!/bin/bash
set -e
supervisorctl start push_stream

View File

@ -1,2 +1,4 @@
#!/bin/bash
supervisorctl stop push_stream
set -e
supervisorctl stop test

View File

@ -1,4 +1,8 @@
#!/bin/bash
# TODO git更新
git pull
set -e
# git更新
git pull origin master
# 配置文件复制到supervisor管理
cp -r conf/*.conf /etc/supervisor/conf.d/
# 更新配置文件
supervisorctl reread