Пример #1
0
def refresh_all_server_by_api(api, param=None, gmport_list=None):
    ip = ConfigManager.getvalue("ACCSERVER", "host")
    if gmport_list is None:
        recharge_port = ConfigManager.getvalue("ACCSERVER", "configport")
        acc_port = ConfigManager.getvalue("ACCSERVER", "configport2")
        gmport_list = [acc_port, recharge_port]
        if "configport3" in ConfigManager._config_dict["ACCSERVER"]:
            resource_port = ConfigManager.getvalue("ACCSERVER", "configport3")
            gmport_list.append(resource_port)

    tag = 0
    for port in gmport_list:
        if param is None:
            status = RequestServer(ip, port, api)
        else:
            status = RequestServer(ip, port, api, param)
        try:
            status = json_decode(status)
            if status['status'] == 'success':
                tag += 1
        except Exception as e:
            logging.info('refresh_server_list fail: %s' % e)

    return_status = 'success' if tag == len(gmport_list) else 'fail'
    return {'status': return_status}
Пример #2
0
def cdkey_info():
    '''
    获取cdkey的ip和port
    :return:
    '''
    ip = ConfigManager.getvalue('CDKEY', 'ip')
    port = ConfigManager.getvalue('CDKEY', 'port')
    return {'ip': ip, 'port': port}
Пример #3
0
 def get(self):
     '''
     获取网站信息
     :return:
     '''
     data = {'title': '侯广东', 'platform_name': '广东渠道', 'platform_group': '广东游戏'}
     data['title'] = ConfigManager.getvalue('WEB_INFO', 'title')
     data['platform_name'] = ConfigManager.getvalue('WEB_INFO', 'platform')
     data['platform_group'] = ConfigManager.getvalue('WEB_INFO', 'platform_group')
     return_data = {'status': 'ok', 'data': data}
     self.write(return_data)
Пример #4
0
def set_service(acc_tag, method, user, real_ip):
    host_ip = ConfigManager.getvalue("ACCSERVER", "host")
    port = ConfigManager.getvalue("ACCSERVER", "port")
    if method == 1 or method == 3:
        opt_str = "账号服务"
    elif method == 2:
        opt_str = "资源服务"
    elif method == 4:
        opt_str = "充值服务"
    else:
        opt_str = "账号总服务"

    send_data = {"method": method}

    if acc_tag == 1:
        str_ope = "startserver"
        opt_str2 = "启动"
    else:
        str_ope = "stopserver"
        opt_str2 = "关闭"
    logging.info(opt_str2 + opt_str)
    SystemLogObject().insert_log(user, 10, opt_str2 + opt_str, real_ip)
    return RequestServer(host_ip, port, str_ope, send_data)
Пример #5
0
def notice_agent(ip=""):
    # 获取agent服务器的IP地址和端口
    if ip:
        game_list = query_all_server(ip=ip)
    else:
        game_list = query_all_server()
    agent_port = ConfigManager.getvalue("Agent", "port")
    game_dict = {}
    if game_list:
        for ga in game_list:
            if ga["ip"] not in game_dict:
                game_dict[ga["ip"]] = {}
            game_dict[ga["ip"]][ga["gameid"]] = ga
            game_dict[ga["ip"]][ga["gameid"]]["port"] = ga["port"]

        for g in game_dict:
            send_data = {"data": game_dict[g]}
            RequestServer(g, agent_port, "init", send_data, method='POST')
Пример #6
0
    def __init__(self):
        handlers = [
            # 接口
            (r"/get/web_info", GetWebInfo),                             # 获取网站信息
            # Default
            (r"/", forwardhandlers.IndexHandler),                       # 主页页面
            (r"/login", forwardhandlers.LoginHandler),                  # 登录页面
            (r"/updatepass", datahandlers.UpdatePassHandler),           # 更新密码
            (r"/exit", forwardhandlers.ExitHandler),                    # 退出页面
            # 管理系统 Route
            (r"/server", forwardhandlers.ServerHandler),                # 管理系统

            # 统计系统
            (r"/trend", forwardhandlers.TrendHandler),                  # 统计系统

            # 策划系统
            (r"/config/configfile", configfilehandler.ConfigFileHandler),   # 策划系统


            # 运维系统
            (r"/allgame_b/total", forwardhandlers.AllGameBTotalHandler),    # 运维系统

            # 运营系统 Route
            (r"/broadcast", forwardhandlers.BroadcastHandler),          # 运营系统 Route

            # AJax Route
            (r"/validate", datahandlers.AjaxValidateHandler),           # 验证
            (r"/getalluser", datahandlers.AjaxGetAllUserHandler),       # 获取所有用户
            # (r"/getotheruser", datahandlers.AjaxGetOtherUserHandler),
            (r"/operateuser", datahandlers.AjaxOperateUserHandler),     # 更新或添加用户
            (r"/deleteuser", datahandlers.AjaxDeleteUserHandler),       # 删除用户
        ]

        key = ConfigManager.getvalue("GAME_DATA", "config_path")
        cookie_secret = hashlib.md5(key).hexdigest()
        settings = dict(
            login_url="/login",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            cookie_secret=uuid.uuid4(),
            xsrf_cookies=False,
            debug=True
        )
        tornado.web.Application.__init__(self, handlers, **settings)
Пример #7
0
        settings = dict(
            login_url="/login",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            cookie_secret=uuid.uuid4(),
            xsrf_cookies=False,
            debug=True
        )
        tornado.web.Application.__init__(self, handlers, **settings)


def main():
    http_server = Application()
    print "Starting server on port %d....." % options.port
    # http_server.listen(options.port, address='127.0.0.1', xheaders=True)
    http_server.listen(options.port, xheaders=True)
    s_time = 5 * 60 * 1000
    if options.identity == 1:
        tornado.ioloop.PeriodicCallback(PushBroadcast2, s_time).start()
    tornado.ioloop.IOLoop.instance().start()


if __name__ == '__main__':
    tornado.options.parse_command_line()
    ConfigManager.create("config.ini")
    DBHelperObject.init_connection()
    if options.identity == 1:
        account_handler.notice_acc_agent()
        notice_agent()

    main()
Пример #8
0
def get_account_server_status():
    host_ip = ConfigManager.getvalue("ACCSERVER", "host")
    port = ConfigManager.getvalue("ACCSERVER", "port")
    return RequestServer(host_ip, port, "serverstatus")
Пример #9
0
def notice_acc_agent():
    log_path = ConfigManager.getvalue("ACCSERVER", "logpath")
    acc_path = ConfigManager.getvalue("ACCSERVER", "path")
    port = ConfigManager.getvalue("ACCSERVER", "port")
    ip = ConfigManager.getvalue("ACCSERVER", "host")
    config_path = ConfigManager.getvalue("ACCSERVER", "config_path")
    pay_port = ""
    if "runport2" in ConfigManager._config_dict["ACCSERVER"]:
        pay_port = ConfigManager.getvalue("ACCSERVER", "runport2")
    if "runport3" in ConfigManager._config_dict["ACCSERVER"]:
        acc_port = ConfigManager.getvalue("ACCSERVER", "runport3")
        res_port = ConfigManager.getvalue("ACCSERVER", "runport")
    else:
        acc_port = ConfigManager.getvalue("ACCSERVER", "runport")
        res_port = ""
    global_port = ConfigManager.getvalue("GLOBALSERVER", "port")
    global_log_path = ConfigManager.getvalue("GLOBALSERVER", "logpath")
    global_config_path = ConfigManager.getvalue("GLOBALSERVER", "config_path")
    global_path = ConfigManager.getvalue("GLOBALSERVER", 'path')
    send_data = {
        "data": {
            "acc": {
                "log_path": log_path,
                "config_path": config_path,
                "acc_path": acc_path,
                "res_port": res_port,
                "acc_port": acc_port,
                "pay_port": pay_port,
            },
            "global": {
                "log_path": global_log_path,
                "config_path": global_config_path,
                "port": global_port,
                "global_path": global_path
            }
        }
    }
    logging.info("init...%s" % send_data)
    RequestServer(ip, port, "init", send_data, method='POST')