This commit is contained in:
2025-01-11 14:50:08 +01:00
parent 9b86632efc
commit f6efdcc56e

View File

@ -19,7 +19,9 @@ pid = os.getpid()
host = platform.node().lower()
cmnd = "ps -ef|grep omv_backups.py|grep -v grep |grep -v {}|wc -l".format(pid)
status, output = subprocess.getstatusoutput(cmnd)
if int(output) > 0:
print("Running already!")
sys.exit()
def is_port_open(host, port):
try:
sock = socket.create_connection((host, port))
@ -29,13 +31,14 @@ def is_port_open(host, port):
return False
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# doesn't even have to be reachable
s.connect(('192.168.77.1', 1))
IP = s.getsockname()[0]
print(IP)
print(output)
if int(output) > 0:
print("Running already!")
sys.exit()
conn = False
while not conn:
s.connect(('192.168.77.1', 1))
IP = s.getsockname()[0]
print(IP)
print(output)
time.sleep(5)
broker = 'mqtt.home.lan'
port = 1883
topic_sum = "sectorq/omv/backups"