提交 1e9ee9dc authored 作者: blu's avatar blu

ota updater revise: networking issues

上级 5b3a598b
*/5 * * * * sync; echo 1 > /proc/sys/vm/drop_caches
*/3 * * * * python /root/work/opencv-pocs/opencv-motion-detect/upload_video.py >>/var/log/syslog
*/10 * * * * python /root/work/opencv-pocs/opencv-motion-detect/updater.py >>/var/log/syslog
[Unit]
Description= manages updater.py
# #for wifi only
# After=evwifi.service
# #for eth0 only
After=network-online.target
Wants=network-online.target
# #for both
# After=network-online.target evwifi.service
# Wants=network-online.target evwifi.service
[Service]
Type=simple
ExecStart=/usr/bin/python /root/work/opencv-pocs/opencv-motion-detect/updater.py >> /var/log/syslog
WorkingDirectory=/root/work/opencv-pocs/opencv-motion-detect
Restart=always
RestartSec=10
StartLimitIntervalSec=0
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=evsuits
[Install]
WantedBy=multi-user.target
\ No newline at end of file
......@@ -137,7 +137,17 @@ class OTAClient:
#self.client.loop_start()
def run(self):
retry = 0
while retry < 3:
try:
self.client.loop_forever()
except Exception as e:
logger.error("network failure - failed to connect mqtt host: {}".format(str(e)))
# NOTE: reset network and evdaemon
os.system("systemctl restart networking; systemctl restart evdaemon")
retry += 1
# NOTE: IT SHOULD NEVER REACH HERE unless network issues.
logger.error("exiting since network failure")
def run_nonblock(self):
self.client.loop_start()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论