Example #1
0
 def __init__(self, config_path):
     """
     Constructor
     """
     self.Config = ConfigParser.ConfigParser()
     self.Config.read(config_path)
     Logger.openlog()
     self.Server = TCPASyncServer(self.Config)
     RedisConn.init_redis(self.Config)
Example #2
0
class Ratelimitd(object):
    """
    This class is responsible to start the entire app
    """

    def __init__(self, config_path):
        """
        Constructor
        """
        self.Config = ConfigParser.ConfigParser()
        self.Config.read(config_path)
        Logger.openlog()
        self.Server = TCPASyncServer(self.Config)
        RedisConn.init_redis(self.Config)

    def run(self, argv):
        if len(argv) == 2:
            if 'start' == argv[1]:
                self.Server.start()
            elif 'stop' == argv[1]:
                self.Server.stop()
            elif 'restart' == argv[1]:
                self.Server.restart()
            else:
                print "Unknown command"
                sys.exit(2)
            sys.exit(1)
        else:
            print "usage: %s start|stop|restart" % sys.argv[0]
            sys.exit(2)