update
This commit is contained in:
parent
a2210b4624
commit
1b4e49f992
25
MQTT.py
25
MQTT.py
|
@ -5,16 +5,37 @@ import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
from tool import push_stream, close_stream, update, exec_sh, get_record, get_list_record, get_status
|
from tool import push_stream, close_stream, update, exec_sh, get_record, get_list_record, get_status
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
device_name = os.getenv('device_name')
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
client.subscribe('lot_mqtt')
|
client.subscribe('lot_mqtt')
|
||||||
|
|
||||||
|
|
||||||
|
def valid(msg, client):
|
||||||
|
origin_data = json.loads(msg.payload.decode('utf-8'))
|
||||||
|
dev_num = origin_data['device_name']
|
||||||
|
if dev_num is None:
|
||||||
|
client.publish('error', payload='dev_num must be supplied', qos=0)
|
||||||
|
return False
|
||||||
|
if dev_num != device_name:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Message receiving callback
|
# Message receiving callback
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
|
if valid(msg, client) is False:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
data = json.loads(msg.payload.decode('utf-8'))["msg"]
|
origin_data = json.loads(msg.payload.decode('utf-8'))
|
||||||
|
data = origin_data["msg"]
|
||||||
|
if data is None:
|
||||||
|
client.publish('error', payload='msg must be supplied', qos=0)
|
||||||
|
return
|
||||||
if data == "push_stream":
|
if data == "push_stream":
|
||||||
# 启动推流视频
|
# 启动推流视频
|
||||||
push_stream(client)
|
push_stream(client)
|
||||||
|
@ -38,7 +59,7 @@ def on_message(client, userdata, msg):
|
||||||
get_status(client)
|
get_status(client)
|
||||||
else:
|
else:
|
||||||
# 错误类型
|
# 错误类型
|
||||||
client.publish('success', payload='No Such Type', qos=0)
|
client.publish('error', payload='No Such Type', qos=0)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#
|
0 0 * * * /usr/bin/bash /home/pi/lot_manager/delete_than.sh
|
||||||
0 0 * * * /usr/bin/bash /home/pi/delete_than24.sh
|
*/15 * * * * /usr/bin/bash /home/pi/lot_manager/cron_delete_mp4.sh
|
||||||
*/15 * * * * /usr/bin/bash /home/pi/cron_delete_mp4.sh
|
|
||||||
|
|
||||||
|
|
1
tool.py
1
tool.py
|
@ -52,6 +52,7 @@ def update(client):
|
||||||
def get_list_record():
|
def get_list_record():
|
||||||
data = {
|
data = {
|
||||||
"data": os.listdir(mp4_path)
|
"data": os.listdir(mp4_path)
|
||||||
|
|
||||||
}
|
}
|
||||||
requests.post("http://shop.lihaink.cn/api/index/file_list", json=data)
|
requests.post("http://shop.lihaink.cn/api/index/file_list", json=data)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -e
|
||||||
git pull origin master --force
|
git pull origin master --force
|
||||||
# 配置文件复制到supervisor管理
|
# 配置文件复制到supervisor管理
|
||||||
cp -r conf/*.conf /etc/supervisor/conf.d/
|
cp -r conf/*.conf /etc/supervisor/conf.d/
|
||||||
|
cp -r var_conf/push_stream_ + $device_name
|
||||||
# 更新配置文件
|
# 更新配置文件
|
||||||
supervisorctl reread
|
supervisorctl reread
|
||||||
supervisorctl update
|
supervisorctl update
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[program:push_stream]
|
[program:push_stream]
|
||||||
directory=/home/pi/lot_manager
|
directory=/home/pi/lot_manager
|
||||||
command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c copy -preset fast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rstp://47.108.186.87:554/live/test
|
command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c copy -preset fast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rtsp://47.108.186.87:554/live/test
|
||||||
user=pi
|
user=pi
|
||||||
autostart=false
|
autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
Loading…
Reference in New Issue