Пример #1
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.__pinding_hosts = Queue.Queue() # 等待注册的主机
     self.__pinding_services = Queue.Queue() # 等待注册的服务
     self.__pinding_services_death = Queue.Queue() # 用于停止某个服务的心跳
     self.__pinding_hosts_death = Queue.Queue() # 保存需要停止心跳的主机的 mac
     self.daemon = True
     self.__ip = zkutils().myip()
     self.__mac = zkutils().mymac()
     self.start()
Пример #2
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.__pinding_hosts = Queue.Queue()  # 等待注册的主机
     self.__pinding_services = Queue.Queue()  # 等待注册的服务
     self.__pinding_services_death = Queue.Queue()  # 用于停止某个服务的心跳
     self.__pinding_hosts_death = Queue.Queue()  # 保存需要停止心跳的主机的 mac
     self.daemon = True
     self.__ip = zkutils().myip()
     self.__mac = zkutils().mymac()
     self.start()
Пример #3
0
def start():
    app = make_app()
    app.listen(10006)

    log('recording srv starting, using port 10006',
        project='recording',
        level=3)

    global _rcmd
    _rcmd = RecordingCommand()

    global _utils
    _utils = zkutils()

    start_card_server()

    stype = 'recording'
    reglist = gather_sds('recording', '../common/tokens.json')

    #处理本机
    service_url = r'http://<ip>:10006/recording/0/recording'
    local_service_desc = {}
    local_service_desc['type'] = stype
    local_service_desc['id'] = 'recording'
    local_service_desc['url'] = service_url
    _utils = zkutils()
    mac = _utils.mymac()
    local_service_desc['mac'] = mac
    local_service_desc['ip'] = '127.0.0.1'

    reglist.append(local_service_desc)

    log('mac:%s, ip:%s' % (mac, _utils.myip()), project='recording', level=3)

    global _class_schedule
    _class_schedule = Schedule(None)
    for reg in reglist:
        _class_schedule.analyse_json(reg['ip'], reg['mac'])
    _class_schedule.restart_rtmp_living()
    _class_schedule.set_recording_dir()
    del_dir_schedule()

    global rh
    rh = RegHt(reglist)

    global _ioloop
    _ioloop = IOLoop.instance()
    log('running ...', project='recording', level=3)
    _ioloop.start()
    log('terminated!!!!!', project='recording', level=3)
Пример #4
0
def start():
    app = make_app()
    app.listen(10006)

    log('recording srv starting, using port 10006', project='recording', level = 3)

    global _rcmd
    _rcmd = RecordingCommand()

    global _utils
    _utils = zkutils()

    start_card_server()

    stype = 'recording'
    reglist = gather_sds('recording', '../common/tokens.json')

    #处理本机
    service_url = r'http://<ip>:10006/recording/0/recording'
    local_service_desc = {}
    local_service_desc['type'] = stype
    local_service_desc['id'] = 'recording'
    local_service_desc['url'] = service_url
    _utils = zkutils()
    mac = _utils.mymac()
    local_service_desc['mac'] = mac
    local_service_desc['ip'] = '127.0.0.1'
    
    reglist.append(local_service_desc)

    log('mac:%s, ip:%s' % (mac, _utils.myip()), project='recording', level = 3)

    global _class_schedule
    _class_schedule = Schedule(None)
    for reg in reglist:
        _class_schedule.analyse_json(reg['ip'],reg['mac'])
    _class_schedule.restart_rtmp_living()
    _class_schedule.set_recording_dir()
    del_dir_schedule()

    global rh
    rh = RegHt(reglist)

    global _ioloop
    _ioloop = IOLoop.instance()
    log('running ...', project='recording', level = 3)
    _ioloop.start()
    log('terminated!!!!!', project='recording', level=3)
Пример #5
0
def main():
    # 正常启动 ..
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    curr_path = os.path.dirname(os.path.abspath(__file__)) 
    if _uname == 'Linux':
        # 目前linux下仅仅作为代理,暂时不要自动更新
        pass
    else:
        chk_update()
    os.chdir(curr_path)

    if _uname == 'Linux':
        pass
    else:
        import chk_info
        chk_info.wait()

    _zkutils = zkutils()
    _myip = _zkutils.myip_real()

    _mac = _zkutils.mymac()
    global rh, _tokens
    
    service_url = r'http://%s:10000/dm'%(_myip)
    hds = gather_hds_from_tokens(_tokens)
    hds.append({'mac': _mac, 'ip': _myip, 'type': 'dm', 'url' : service_url, 'id': 'dm'}) 
    RegHost(hds)

    if _uname == 'Linux':
        # FIXME: 目前 linux 下仅仅支持代理模式即可
        from common.reght import RegHt
        from common.uty_token import *
        sds = gather_sds('dm', '../common/tokens.json')
        rh = RegHt(sds)
    else:
        # 貌似在 windows 下,如果相同进程中执行 reg_dm,会导致异常,原因不明,所以放在独立进程中
        os.system('start c:/Python27/python reg_dm.py')

    # 启动 ping
    thread.start_new_thread(ping_all,('../common/tokens.json',))
    # 服务管理器,何时 close ??
    _sm = ServicesManager.ServicesManager(_myip, _myip)

    app = make_app()
    DMS_PORT = 10000
    app.listen(DMS_PORT)
    _ioloop.start()

    # 此时,必定执行了 internal?command=exit,可以执行销毁 ...
    print 'DM end ....'
    _sm.close()
Пример #6
0
def main():
    # 正常启动 ..
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    curr_path = os.path.dirname(os.path.abspath(__file__))
    chk_update()
    os.chdir(curr_path)

    import chk_info
    chk_info.wait()

    _zkutils = zkutils()
    _myip = _zkutils.myip_real()

    _mac = _zkutils.mymac()
    global rh, _tokens

    service_url = r'http://%s:10000/dm' % (_myip)
    hds = gather_hds_from_tokens(_tokens)
    hds.append({
        'mac': _mac,
        'ip': _myip,
        'type': 'dm',
        'url': service_url,
        'id': 'dm'
    })
    RegHost(hds)

    #sds = gather_sds_from_tokens(_tokens, "dm")
    #sds.append({'type': 'dm', 'id': 'dm', 'url': service_url})
    #common.reght.verbose = True
    #rh = RegHt(sds)
    os.system('start c:/Python27/python reg_dm.py')

    # 启动 ping
    thread.start_new_thread(ping_all, ('../common/tokens.json', ))
    # 服务管理器,何时 close ??
    _sm = ServicesManager.ServicesManager(_myip, _myip)

    app = make_app()
    DMS_PORT = 10000
    app.listen(DMS_PORT)
    _ioloop.start()

    # 此时,必定执行了 internal?command=exit,可以执行销毁 ...
    print 'DM end ....'
    _sm.close()
Пример #7
0
def mainp():
    import chk_info
    chk_info.wait()

    _zkutils = zkutils()
    _myip = _zkutils.myip_real()

    _mac = _zkutils.mymac()
    global rh, _tokens

    service_url = r'http://%s:10000/dm' % (_myip)
    hds = gather_hds_from_tokens(_tokens)
    hds.append({
        'mac': _myip,
        'ip': _myip,
        'type': 'dm',
        'url': service_url,
        'id': 'dm'
    })
    RegHost(hds)

    #sds = gather_sds_from_tokens(_tokens, "dm")
    #sds.append({'type': 'dm', 'id': 'dm', 'url': service_url})
    #common.reght.verbose = True
    #rh = RegHt(sds)
    #os.system('start c:/Python27/python reg_dm.py')

    a = 'python reg_dm.py'
    import shlex
    args = shlex.split(a)
    subprocess.Popen(args)

    # 启动 ping
    thread.start_new_thread(ping_all, ('../common/tokens.json', ))
    # 服务管理器,何时 close ??
    global _sm
    _sm = ServicesManager.ServicesManager(_myip, _myip)

    app = make_app()
    global DMS_PORT
    app.listen(DMS_PORT)
    _ioloop.start()

    # 此时,必定执行了 internal?command=exit,可以执行销毁 ...
    print 'DM end ....'
    _sm.close()
Пример #8
0
def main():
    # 正常启动 ..
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    chk_update()

    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    import chk_info

    chk_info.wait()

    _zkutils = zkutils()
    _myip = _zkutils.myip_real()

    _mac = _zkutils.mymac()
    global rh, _tokens

    service_url = r"http://%s:10000/dm" % (_myip)
    hds = gather_hds_from_tokens(_tokens)
    hds.append({"mac": _myip, "ip": _myip, "type": "dm", "url": service_url, "id": "dm"})
    RegHost(hds)

    # sds = gather_sds_from_tokens(_tokens, "dm")
    # sds.append({'type': 'dm', 'id': 'dm', 'url': service_url})
    # common.reght.verbose = True
    # rh = RegHt(sds)
    os.system("start c:/Python27/python reg_dm.py")

    # 启动 ping
    thread.start_new_thread(ping_all, ("../common/tokens.json",))
    # 服务管理器,何时 close ??
    global _sm
    _sm = ServicesManager.ServicesManager(_myip, _myip)

    app = make_app()
    global DMS_PORT
    app.listen(DMS_PORT)
    _ioloop.start()

    # 此时,必定执行了 internal?command=exit,可以执行销毁 ...
    print "DM end ...."
    _sm.close()
Пример #9
0
def mainp():
    import chk_info
    chk_info.wait()

    _zkutils = zkutils()
    _myip = _zkutils.myip_real()

    _mac = _zkutils.mymac()
    global rh, _tokens
    
    service_url = r'http://%s:10000/dm'%(_myip)
    hds = gather_hds_from_tokens(_tokens)
    hds.append({'mac': _myip, 'ip': _myip, 'type': 'dm', 'url' : service_url, 'id': 'dm'}) 
    RegHost(hds)

    #sds = gather_sds_from_tokens(_tokens, "dm")
    #sds.append({'type': 'dm', 'id': 'dm', 'url': service_url})
    #common.reght.verbose = True
    #rh = RegHt(sds)
    #os.system('start c:/Python27/python reg_dm.py')

    a = 'python reg_dm.py'
    import shlex
    args = shlex.split(a)
    subprocess.Popen(args)

    # 启动 ping
    thread.start_new_thread(ping_all,('../common/tokens.json',))
    # 服务管理器,何时 close ??
    global _sm
    _sm = ServicesManager.ServicesManager(_myip, _myip)

    app = make_app()
    global DMS_PORT
    app.listen(DMS_PORT)
    _ioloop.start()

    # 此时,必定执行了 internal?command=exit,可以执行销毁 ...
    print 'DM end ....'
    _sm.close()