#coding=utf-8 import time from mq import MessageQueue from threading import Thread, Lock from utils import get_time from log import get_logger addr = { "host": "127.0.0.1", "port": 6379, } r = MessageQueue(**addr) logger = get_logger('debug.log') class SchedulerWorker(object): def __init__(self, queue, thread_num=5): r.set_queue(queue) self.mutex = Lock() self.thread_num = thread_num def run(self): self.spawn_worker() def spawn_worker(self): t_list = [] for th_i in range(self.thread_num): t_threading = Thread(target=self.spawn_handler, args=()) t_list.append(t_threading)
log = logging.getLogger(__name__) log.info(u"Server port = %d.", settings.PORT) log.info(u"Server addr = %s.", settings.BIND_ADDRESS) log.info(u"Public path = %s.", settings.PUBLIC_PATH) # Set up the database db_init(settings.DATABASE_CONFIG) # Just log success log.info(u"Init OK & server running.") # IO Loop for websockets and the amqp stuff io_loop = ioloop.IOLoop.instance() # Set up the message queues mq = MessageQueue(io_loop) mq.connect() # SockJS interface sockClass = UtuputkiSock sockClass.mq = mq router = SockJSRouter(sockClass, '/sock', dict(mq=mq)) # Index and static handlers handlers = router.urls + [ (r'/video/(.*)$', web.StaticFileHandler, { 'path': settings.CACHE_DIR }), (r'/(.*)$', web.StaticFileHandler, { 'path': settings.PUBLIC_PATH, 'default_filename': 'index.html'