Meilleur redémarrage après erreur
This commit is contained in:
parent
f71d5eec14
commit
0640c90489
34
main.py
34
main.py
|
@ -84,22 +84,27 @@ if __name__ == '__main__':
|
|||
if not nick:
|
||||
nick = "Isengard"
|
||||
|
||||
xmpp = MUCBot(jid, password, rooms.split(","), nick)
|
||||
xmpp.register_plugin('xep_0030') # Service Discovery
|
||||
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
||||
|
||||
# Create buffer
|
||||
store = DataStore(xmpp)
|
||||
xmpp.datastore = store
|
||||
|
||||
localservthread = LocalServer(store)
|
||||
localservthread.start()
|
||||
|
||||
ERRORS = 0
|
||||
store = None
|
||||
localservthread = None
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
|
||||
xmpp = MUCBot(jid, password, rooms.split(","), nick)
|
||||
xmpp.register_plugin('xep_0030') # Service Discovery
|
||||
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
||||
|
||||
# Create buffer
|
||||
if not store:
|
||||
store = DataStore(xmpp)
|
||||
xmpp.datastore = store
|
||||
|
||||
# Launch local server
|
||||
if not localservthread:
|
||||
localservthread = LocalServer(store)
|
||||
localservthread.start()
|
||||
time.sleep(1)
|
||||
|
||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||
xmpp.connect()
|
||||
|
@ -113,9 +118,10 @@ if __name__ == '__main__':
|
|||
except KeyboardInterrupt:
|
||||
cleanExit()
|
||||
except Exception as e:
|
||||
log.error(str(e))
|
||||
log.error("ERROR IN MAIN : " + str(e))
|
||||
if ERRORS >= 3:
|
||||
log.critical("3 consecutive errors. Aborting...")
|
||||
cleanExit()
|
||||
|
||||
ERRORS += 1
|
||||
del xmpp
|
||||
|
|
Loading…
Reference in New Issue