This commit is contained in:
xyj 2024-03-05 11:10:00 +08:00
parent 41b563838c
commit 00bccdb21c
2 changed files with 4 additions and 2 deletions

View File

@ -33,6 +33,7 @@ class MQTTClient:
self.client.subscribe(self.topic) self.client.subscribe(self.topic)
client.publish(info_topic, payload=publish_payload(code=200, msg='成功订阅' + self.topic), client.publish(info_topic, payload=publish_payload(code=200, msg='成功订阅' + self.topic),
qos=0) qos=0)
subprocess.Popen(['/bin/bash /home/pi/agri_xumu/bash/start_push_stream.sh'], shell=True)
def on_message(self, client, userdata, msg): def on_message(self, client, userdata, msg):
if not valid(msg, client): if not valid(msg, client):
@ -79,4 +80,5 @@ if __name__ == '__main__':
MQTT.client.loop_forever() MQTT.client.loop_forever()
except Exception as e: except Exception as e:
# 异常等待时间在进行连接 # 异常等待时间在进行连接
subprocess.Popen(['/bin/bash /home/pi/agri_xumu/bash/stop_push_stream.sh'], shell=True)
time.sleep(30) time.sleep(30)

View File

@ -2,8 +2,8 @@
directory=/home/pi/agri_xumu/bash directory=/home/pi/agri_xumu/bash
command=/usr/bin/bash stream.sh command=/usr/bin/bash stream.sh
user=pi user=pi
autostart=true autostart=false
autorestart=true autorestart=false
redirect_stderr=true redirect_stderr=true
stopsignal=TERM stopsignal=TERM
stopasgroup=True stopasgroup=True