Minimal multi-stage docker build

This commit is contained in:
timothymiller
2020-08-05 03:25:13 -04:00
parent a1e1348214
commit df6b8a381a
8 changed files with 73 additions and 81 deletions

View File

@@ -104,6 +104,27 @@ def cf_api(endpoint, method, config, headers={}, data=False):
return response.json()
for ip in getIPs():
print("Checking " + ip["type"] + " records")
commitRecord(ip)
# Scheduling
import time, traceback
def every(delay, task):
next_time = time.time() + delay
while True:
time.sleep(max(0, next_time - time.time()))
try:
task()
except Exception:
traceback.print_exc()
# in production code you might want to have this instead of course:
# logger.exception("Problem while executing repetitive task.")
# skip tasks if we are behind schedule:
next_time += (time.time() - next_time) // delay * delay + delay
def updateIPs():
for ip in getIPs():
print("Checking " + ip["type"] + " records")
commitRecord(ip)
updateIPs()
import threading
threading.Thread(target=lambda: every(60*15, updateIPs)).start()