# -*- coding: utf-8 -*-
+import logging
import signal
from time import sleep
from distbot.bot import worker as worker_mod
-from distbot.plugins import basic, fun, lookup, url, feeds, muc, translation, searx, queue_management, plugin_help, \
- morse, meta, \
- extended, bugtracker, bots, bofh
+from distbot.plugins import (
+ basic, fun, lookup, url, feeds, muc, translation, searx, queue_management, plugin_help,
+ morse, meta,
+ extended, bugtracker, bots, bofh,
+ debug
+)
+logger = logging.getLogger(__name__)
WORKER_QUEUE = "work"
# TODO read from config
searx: searx.ALL,
translation: translation.ALL,
url: url.ALL,
+ # debug: debug.ALL
}
job_workers = []
def stop_workers(signum, frame):
- print("stopping workers")
+ logger.info("stopping workers")
[t.die() for t in job_workers]
- print("joining workers")
+ logger.info("joining workers")
[t.join() for t in job_workers]
- print("stopped workers.")
+ logger.info("stopped workers.")
job_workers.clear()
# signal.signal(signal.SIGHUP, reset_workers)
signal.signal(signal.SIGALRM, dump_status)
initialize_workers()
- while True:
- sleep(100)
+ try:
+ while True:
+ sleep(100)
+ except KeyboardInterrupt:
+ import os
+ os.kill(os.getpid(), signal.SIGTERM)
+ logger.info("Exiting...")
+ exit(0)
if __name__ == '__main__':