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