mirror of
https://github.com/timothymiller/cloudflare-ddns.git
synced 2026-03-21 22:48:57 -03:00
Minimal multi-stage docker build
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user