mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 23:23:52 +01:00
Fehler bei Hashwerte bei Dateien behoben
Neuanordnugn für Reload der Dienste bei Dateiänderungen
This commit is contained in:
@@ -605,7 +605,7 @@ class RevPiPyLoad():
|
|||||||
self.pictorymtime = mtime
|
self.pictorymtime = mtime
|
||||||
|
|
||||||
with open(proginit.pargs.configrsc, "rb") as fh:
|
with open(proginit.pargs.configrsc, "rb") as fh:
|
||||||
file_hash = md5(fh.read())
|
file_hash = md5(fh.read()).hexdigest()
|
||||||
if self.pictoryhash == file_hash:
|
if self.pictoryhash == file_hash:
|
||||||
return False
|
return False
|
||||||
self.pictoryhash = file_hash
|
self.pictoryhash = file_hash
|
||||||
@@ -639,7 +639,7 @@ class RevPiPyLoad():
|
|||||||
self.replaceiosmtime = mtime
|
self.replaceiosmtime = mtime
|
||||||
|
|
||||||
with open(self.replace_ios_config, "rb") as fh:
|
with open(self.replace_ios_config, "rb") as fh:
|
||||||
file_hash = md5(fh.read())
|
file_hash = md5(fh.read()).hexdigest()
|
||||||
if self.replaceiohash == file_hash:
|
if self.replaceiohash == file_hash:
|
||||||
return False
|
return False
|
||||||
self.replaceiohash = file_hash
|
self.replaceiohash = file_hash
|
||||||
@@ -721,14 +721,37 @@ class RevPiPyLoad():
|
|||||||
self.plc.start()
|
self.plc.start()
|
||||||
|
|
||||||
# mainloop
|
# mainloop
|
||||||
file_changed = False
|
|
||||||
while not self._exit:
|
while not self._exit:
|
||||||
|
file_changed = False
|
||||||
|
|
||||||
# Neue Konfiguration laden
|
# Neue Konfiguration laden
|
||||||
if self.evt_loadconfig.is_set():
|
if self.evt_loadconfig.is_set():
|
||||||
proginit.logger.info("got reqeust to reload config")
|
proginit.logger.info("got reqeust to reload config")
|
||||||
self._loadconfig()
|
self._loadconfig()
|
||||||
|
|
||||||
|
# Dateiveränderungen prüfen mit beiden Funktionen!
|
||||||
|
if self.check_pictory_changed():
|
||||||
|
file_changed = True
|
||||||
|
proginit.logger.warning("piCtory configuration was changed")
|
||||||
|
if self.check_replace_ios_changed():
|
||||||
|
file_changed = True
|
||||||
|
proginit.logger.warning("replace ios file was changed")
|
||||||
|
if file_changed:
|
||||||
|
# Auf Dateiveränderung reagieren
|
||||||
|
|
||||||
|
# MQTT Publisher neu laden
|
||||||
|
if self.mqtt and self.th_plcmqtt is not None:
|
||||||
|
self.th_plcmqtt.reload_revpimodio()
|
||||||
|
|
||||||
|
# ProcImgServer anhalten zum neu laden
|
||||||
|
self.stop_plcslave()
|
||||||
|
|
||||||
|
# XML Prozessabbildserver neu laden
|
||||||
|
if self.xml_ps is not None:
|
||||||
|
self.xml_psstop()
|
||||||
|
self.xml_ps.loadrevpimodio()
|
||||||
|
# Kein psstart um Reload im Client zu erzeugen
|
||||||
|
|
||||||
# MQTT Publisher Thread prüfen
|
# MQTT Publisher Thread prüfen
|
||||||
if self.mqtt and self.th_plcmqtt is not None \
|
if self.mqtt and self.th_plcmqtt is not None \
|
||||||
and not self.th_plcmqtt.is_alive():
|
and not self.th_plcmqtt.is_alive():
|
||||||
@@ -742,38 +765,14 @@ class RevPiPyLoad():
|
|||||||
# PLC Server Thread prüfen
|
# PLC Server Thread prüfen
|
||||||
if self.plcslave and self.th_plcslave is not None \
|
if self.plcslave and self.th_plcslave is not None \
|
||||||
and not self.th_plcslave.is_alive():
|
and not self.th_plcslave.is_alive():
|
||||||
proginit.logger.warning(
|
if not file_changed:
|
||||||
"restart plc slave after thread was not running"
|
proginit.logger.warning(
|
||||||
)
|
"restart plc slave after thread was not running"
|
||||||
|
)
|
||||||
self.th_plcslave = self._plcslave()
|
self.th_plcslave = self._plcslave()
|
||||||
if self.th_plcslave is not None:
|
if self.th_plcslave is not None:
|
||||||
self.th_plcslave.start()
|
self.th_plcslave.start()
|
||||||
|
|
||||||
# Dateiveränderungen prüfen mit beiden Funktionen!
|
|
||||||
if self.check_pictory_changed():
|
|
||||||
file_changed = True
|
|
||||||
proginit.logger.warning("piCtory configuration was changed")
|
|
||||||
if self.check_replace_ios_changed():
|
|
||||||
file_changed = True
|
|
||||||
proginit.logger.warning("replace ios file was changed")
|
|
||||||
if file_changed:
|
|
||||||
file_changed = False
|
|
||||||
|
|
||||||
# Auf Dateiveränderung reagieren
|
|
||||||
|
|
||||||
# MQTT Publisher neu laden
|
|
||||||
if self.mqtt and self.th_plcmqtt is not None:
|
|
||||||
self.th_plcmqtt.reload_revpimodio()
|
|
||||||
|
|
||||||
# FIXME: ProcImgServer muss alle Verbindungen vernichten
|
|
||||||
# NOTE: RevPiNetIO müsste bei Neuverbindung Hashs abfragen
|
|
||||||
|
|
||||||
# XML Prozessabbildserver neu laden
|
|
||||||
if self.xml_ps is not None:
|
|
||||||
self.xml_psstop()
|
|
||||||
self.xml_ps.loadrevpimodio()
|
|
||||||
# Kein psstart um Reload im Client zu erzeugen
|
|
||||||
|
|
||||||
self.evt_loadconfig.wait(1)
|
self.evt_loadconfig.wait(1)
|
||||||
|
|
||||||
proginit.logger.info("stopping revpipyload")
|
proginit.logger.info("stopping revpipyload")
|
||||||
|
|||||||
Reference in New Issue
Block a user