#!/usr/bin/env python3

from fakeredis import TcpFakeServer
import structlog

logger = structlog.get_logger()


def main(hostname="localhost", port=6379):
    server = TcpFakeServer((hostname, port))
    logger.info("Listening on port {}".format(port))
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        logger.info("User requested shutdown.")
    finally:
        server.server_close()
        logger.info("Redis is now ready to exit.")
    return 0


if __name__ == "__main__":
    main()
