plugin loader, graceful shutdown!

This commit is contained in:
Luke Rogers 2013-10-02 19:25:16 +13:00
parent 9d0f9248ff
commit e6318fe725
7 changed files with 136 additions and 133 deletions

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python
# we import bot as _bot for now, for legacy reasons
from core import bot as _bot
from core import bot
import os
import sys
@ -12,17 +11,17 @@ os.chdir(sys.path[0] or '.') # do stuff relative to the install directory
print 'CloudBot REFRESH <http://git.io/cloudbotirc>'
def exit_gracefully(signum, frame):
bot.stop()
cloudbot.stop()
# store the original SIGINT handler
original_sigint = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, exit_gracefully)
# create new bot object
bot = _bot.Bot("cloudbot")
bot.logger.debug("Bot initalized, starting main loop.")
cloudbot = bot.Bot()
cloudbot.logger.debug("Bot initalized, starting main loop.")
while bot.running:
bot.loop()
while cloudbot.running:
cloudbot.loop()
bot.logger.debug("Stopped main loop.")
cloudbot.logger.debug("Stopped main loop.")