Exemple #1
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()
Exemple #2
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()
Exemple #3
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()
Exemple #4
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()
Exemple #5
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()