Commit be46966e authored by Jelte Jansen's avatar Jelte Jansen
Browse files

save config data on SIGINT and SIGTERM


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@173 e5f2f494-b856-4b98-b285-d166d9295462
parent 7a310b66
import ISC
import pickle
import signal
class ConfigData:
def __init__(self):
......@@ -16,6 +17,7 @@ class ConfigManager:
self.cc = ISC.CC.Session()
self.cc.group_subscribe("ConfigManager")
self.config = ConfigData()
self.running = False
def notify_boss(self):
self.cc.group_sendmsg({"running": "configmanager"}, "Boss")
......@@ -71,8 +73,8 @@ class ConfigManager:
return answer
def run(self):
msg = 1
while (msg):
self.running = True
while (self.running):
msg, env = self.cc.group_recvmsg(False)
if msg:
print("received message: ")
......@@ -82,13 +84,23 @@ class ConfigManager:
print(answer)
self.cc.group_reply(env, answer)
print("answer sent")
else:
self.running = False
cm = None
def signal_handler(signal, frame):
global cm
if cm:
cm.running = False
if __name__ == "__main__":
print("Hello, BIND10 world!")
db_file = "/tmp/parkinglot.db"
try:
cm = ConfigManager()
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
cm.read_config(db_file)
# do loading here if necessary
cm.notify_boss()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment