Ejemplo n.º 1
0
Archivo: run.py Proyecto: tclh123/maria
def main():
    parser = argparse.ArgumentParser()
    populate_argument_parser(parser)
    args = parser.parse_args()

    config.parser(args)
    init_log()

    if args.mode == 'ssh':
        config.worker = load_class('maria.gssh.GSSHServer')
        config.host_key = paramiko.RSAKey(filename=os.path.realpath(config.host_key))
        logger.info('Host Key %s' % hex_key(config.host_key))
        interface = args.interface or 'maria.gssh.GSSHInterface'
        server = StreamServer((args.host, args.port), handle)
    elif args.mode == 'http':
        config.worker = load_class('maria.ghttp.GHTTPServer')
        interface = args.interface or 'maria.ghttp.GHTTPInterface'
        server = WSGIServer((args.host, args.port), GHTTPServer())
    else:
        print 'Not support %s yet, system shutdown!' % args.mode
        sys.exit(-1)

    config.interface = load_class(interface)

    try:
        logger.info('Maria System Start at %s:%d' % (config.host, config.port))
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info('Maria System Stopped')
Ejemplo n.º 2
0
def run(host="0.0.0.0",
        port=2200,
        worker="maria.gssh.GSSHServer",
        interface=""):
    config.host = host
    config.port = port
    config.worker = worker
    config.worker = load_class(worker)

    if worker == "maria.gssh.GSSHServer":
        if interface:
            config.gssh_interface = interface
        config.gssh_interface = load_class(config.gssh_interface)
        config.host_key = paramiko.RSAKey(filename=config.host_key)
        logger.info('Host Key %s' % hex_key(config.host_key))
        server = StreamServer((config.host, config.port), handle)
    else:
        if interface:
            config.ghttp_interface = interface
        config.ghttp_interface = load_class(config.ghttp_interface)
        server = WSGIServer((config.host, config.port), GHTTPServer())

    try:
        logger.info('Maria System Start at %s:%d' % (config.host, config.port))
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info('Maria System Stopped')
Ejemplo n.º 3
0
Archivo: run.py Proyecto: abael/maria
def main():
    parser = argparse.ArgumentParser()
    populate_argument_parser(parser)
    args = parser.parse_args()

    config.parser(args)
    init_log()

    if config.worker == "maria.gssh.GSSHServer":
        config.host_key = paramiko.RSAKey(filename=config.host_key)
        logger.info('Host Key %s' % hex_key(config.host_key))
        server = StreamServer((args.host, args.port), handle)
    else:
        server = WSGIServer((args.host, args.port), GHTTPServer())
    config.worker = load_class(config.worker)
    config.gssh_interface = load_class(config.gssh_interface)
    config.ghttp_interface = load_class(config.ghttp_interface)

    try:
        logger.info('Maria System Start at %s:%d' % (config.host, config.port))
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info('Maria System Stopped')
Ejemplo n.º 4
0
Archivo: run.py Proyecto: lehoon/maria
def main():
    parser = argparse.ArgumentParser()
    populate_argument_parser(parser)
    args = parser.parse_args()

    config.parser(args)
    init_log()
    # init hook file
    from maria import hook
    config.host_key = paramiko.RSAKey(filename=config.host_key)
    config.worker = load_class(config.worker)

    server = StreamServer((args.host, args.port), handle)
    try:
        logger.info('Maria System Start at %s:%d' % (config.host, config.port))
        logger.info('Host Key %s' % hex_key(config.host_key))
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info('Maria System Stopped')