示例#1
0
def start_chitu():
    # load all configs
    all_conf = get_conf('conf/conf.toml')

    # init log config
    setup_logging(all_conf['log_configuration'])

    thread_set = dict()
    queue = None
    workers = list()

    for redis_address in all_conf['redis']['address']:
        work = Transport(all_conf, redis_address)
        work.name = 'redis_' + str(redis_address['db'])
        thread = Thread(target=work.work, args=(), name='%s' % work.name)
        thread.setDaemon(True)
        thread.start()
        workers.append(work)
        thread_set[work.name] = thread

    # start communication instance
    communication = Communication(all_conf)
    thread = Thread(target=communication.work,
                    args=(),
                    name='%s' % communication.name)
    thread.setDaemon(True)
    thread.start()

    # start watch instance
    watch = WatchDog(all_conf)
    watch = Thread(target=watch.work,
                   name='watchdog',
                   args=(thread_set, queue, workers))
    watch.setDaemon(True)
    watch.start()
示例#2
0
    def __init__(self, conf):
        self.redis = RedisWrapper(conf['redis'])
        self.watchdog = WatchDog(conf)
        self.app = conf['application']
        self.data = dict()
        self._name = 'communication'
        self.log = list()
        self.hash = None

        # 20-12-14 zhy: windows启动异常,communication中没有self.paths参数
        self.__init_paths()
        # 重启刷新缓存
        self.flush_data()
示例#3
0
def start_ziyan():
    from plugins.your_plugin import MyCheck, MyHandler

    # init queues
    queue = {'data_queue': Queue(), 'sender': Queue()}

    # load all configs
    all_conf = get_conf('conf/conf.toml')

    # init log config
    setup_logging(all_conf['log_configuration'])

    # init instances
    checker = MyCheck(all_conf)
    handler = MyHandler(all_conf)
    sender = Sender(all_conf)
    communication = Communication(all_conf)

    # name instances
    checker.name = 'checker'
    handler.name = 'handler'
    sender.name = 'sender'

    # init work threads set
    workers = [checker, handler]

    thread_set = dict()

    # start workers instance
    for worker in workers:
        thread = Thread(target=worker.work,
                        args=(queue, ),
                        name='%s' % worker.name)
        thread.setDaemon(True)
        thread.start()
        thread_set[worker.name] = thread

    # init send set
    send_set = [communication, sender]
    for send in send_set:
        thread = Thread(target=send.work,
                        args=(queue, ),
                        name='%s' % send.name)
        thread.setDaemon(True)
        thread.start()

    # start watch instance
    watch = WatchDog(all_conf)
    watch = Thread(target=watch.work,
                   name='%s' % watch.name,
                   args=(thread_set, queue, workers))
    watch.setDaemon(True)
    watch.start()
示例#4
0
    def __init__(self, conf):
        self.redis = RedisWrapper(conf['redis'])
        self.etcd = EtcdWrapper(conf['etcd'])
        self.etcd_interval_time = conf['etcd']['interval']
        self.watchdog = WatchDog(conf)
        self.node = conf['node']
        self.ip = conf['local_ip']
        self.app = conf['application']
        self.paths = conf['paths']
        self.data = dict()
        self._name = 'communication'
        self.log = list()
        self.hash = None

        # 重启刷新缓存
        self.flush_data()