Пример #1
0
    template = {
        "dbname": "",
        "dbnode": "",
        "dbtype": "",
        "dbdisabled": "",
        "username": "",
        "password": "",
        "host_r": "",
        "host_w": "",
        "ips": ""
        }
    dbinfo["password"] = utils.encrypt(dbinfo["password"])
    DBInfo().create_dbinfo(dbinfo)

if __name__ == "__main__":
    utils.gen_logger("dbinfo_znode_logger", "/tmp/l.log")
    options = ["init_znode", "sync_mysql", "init_a_node"]
    if len(sys.argv) < 2:
        utils.log(utils.cur(), "Usage: python %s %s arguments" % (sys.argv[0], "/".join(options)))
        sys.exit(0)
    arg1 = sys.argv[1]
    if not arg1 in options:
        utils.log(utils.cur(), "Usage: python %s %s arguments" % (sys.argv[0], "/".join(options)))
        sys.exit(0)

    utils.parse_args(sys.argv[2:])
    if arg1 == "init_znode":
        # init_znode()
        # print DBType().zk.get_dict("/database")
        DBType().list("/database/db_info/appstat")
        # DBType().zk.set("/database/db_info/appstat/dbconf/db_host_r", "10.11.150.126:3306")
Пример #2
0
        "dbname": "",
        "dbnode": "",
        "dbtype": "",
        "dbdisabled": "",
        "username": "",
        "password": "",
        "host_r": "",
        "host_w": "",
        "ips": ""
    }
    dbinfo["password"] = utils.encrypt(dbinfo["password"])
    DBInfo().create_dbinfo(dbinfo)


if __name__ == "__main__":
    utils.gen_logger("dbinfo_znode_logger", "/tmp/l.log")
    options = ["init_znode", "sync_mysql", "init_a_node"]
    if len(sys.argv) < 2:
        utils.log(
            utils.cur(),
            "Usage: python %s %s arguments" % (sys.argv[0], "/".join(options)))
        sys.exit(0)
    arg1 = sys.argv[1]
    if not arg1 in options:
        utils.log(
            utils.cur(),
            "Usage: python %s %s arguments" % (sys.argv[0], "/".join(options)))
        sys.exit(0)

    utils.parse_args(sys.argv[2:])
    if arg1 == "init_znode":
Пример #3
0
                proobj.close_proobj()
                del proobj

    def stopFactory(self):
        utils.log(utils.cur(), "dbproxy stopping")
        self.zk.close()
        self.mq.stop()
        self.monitor.stop()
        self.proxy_stats_log.stop()
        # time.sleep(0.5)
        self.close_free_servers()
        self.servers.stop()
        stats_conns.close()


utils.gen_logger(ProxyServer.LOGGER, ProxyServer.LOGFILE)
utils.parse_args(sys.argv[1:])
f = ServerFactory(ProxyServer.PORT)


def handler(sig, action):
    from objects_dump import MemObject

    MemObject.dump("/opt/logs/sce_db/dbproxy.txt")


signal.signal(signal.SIGUSR1, handler)
if __name__ == "__main__":
    reactor.listenTCP(ProxyServer.PORT, f)
    reactor.run()
else:
Пример #4
0
                stats_conns.decr(proobj.database)
                proobj.close_proobj()
                del proobj

    def stopFactory(self):
        utils.log(utils.cur(), "dbproxy stopping")
        self.zk.close()
        self.mq.stop()
        self.monitor.stop()
        self.proxy_stats_log.stop()
        # time.sleep(0.5)
        self.close_free_servers()
        self.servers.stop()
        stats_conns.close()

utils.gen_logger(ProxyServer.LOGGER, ProxyServer.LOGFILE)
utils.parse_args(sys.argv[1:])
f = ServerFactory(ProxyServer.PORT)

def handler(sig, action):
    from objects_dump import MemObject
    MemObject.dump("/opt/logs/sce_db/dbproxy.txt")

signal.signal(signal.SIGUSR1, handler)
if __name__ == "__main__":
    reactor.listenTCP(ProxyServer.PORT, f)
    reactor.run()
else:
    uid, gid = utils.getuidgid()
    application = service.Application(ProxyServer.APPLICATION, uid=uid, gid=gid)
    internet.TCPServer(ProxyServer.PORT, f).setServiceParent(application)