Permalink
Browse files

Restart on error & error log

  • Loading branch information...
1 parent 681c4f9 commit 30c46304a48cdffc62095aad8fb50507bdc41f0f @Smotko Smotko committed Oct 16, 2011
Showing with 22 additions and 5 deletions.
  1. 0 src/error_log
  2. +22 −5 src/main.py
View
No changes.
View
@@ -5,11 +5,28 @@
@author: smotko
'''
+from traceback import format_exc
+from datetime import datetime
+from time import sleep
+
if __name__ == '__main__':
from handler import Bot
- # initialize
- mypybot = Bot()
-
- # and run
- mypybot.run('irc.freenode.org', 6667)
+ while True:
+
+ try:
+
+ # initialize
+ mypybot = Bot()
+
+ # and run
+ mypybot.run('irc.freenode.org', 6667)
+
+ except Exception as e:
+
+ f = open('error_log', 'a')
+ f.write(str(datetime.now()) + "\n")
+ f.write(str(format_exc() + "\n\n"))
+ f.close()
+ sleep(1)
+

0 comments on commit 30c4630

Please sign in to comment.