Merge pull request #33 from markormesher/feat/handle-sigterm
handle sigterm and shutdown immediately
This commit is contained in:
commit
6140917119
@ -1,4 +1,4 @@
|
||||
import requests, json, sys, os
|
||||
import requests, json, sys, signal, os
|
||||
import time
|
||||
|
||||
PATH = os.getcwd() + "/"
|
||||
@ -7,6 +7,12 @@ version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1]))
|
||||
if(version < 3.5):
|
||||
raise Exception("This script requires Python 3.5+")
|
||||
|
||||
def sigtermHandler(sig_no, stack_frame):
|
||||
print("Caught SIGTERM, shutting down...")
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, sigtermHandler)
|
||||
|
||||
with open(PATH + "config.json") as config_file:
|
||||
config = json.loads(config_file.read())
|
||||
|
||||
@ -126,6 +132,7 @@ def updateIPs():
|
||||
for ip in getIPs():
|
||||
commitRecord(ip)
|
||||
|
||||
try:
|
||||
if(len(sys.argv) > 1):
|
||||
if(sys.argv[1] == "--repeat"):
|
||||
print("Updating A & AAAA records every 10 minutes")
|
||||
@ -140,3 +147,5 @@ if(len(sys.argv) > 1):
|
||||
print("Unrecognized parameter '" + sys.argv[1] + "'. Stopping now.")
|
||||
else:
|
||||
updateIPs()
|
||||
except SystemExit:
|
||||
print("Goodbye!")
|
||||
|
||||
Reference in New Issue
Block a user