Rev 94 | Rev 1292 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 23-Feb-2010@author: ashish'''import sysfrom getopt import getopt, GetoptErrorfrom shop2020.config.impl.ConfigServerHandler import ConfigServerHandlerfrom thrift.protocol.TBinaryProtocol import TBinaryProtocolFactoryfrom shop2020.thriftpy.config import Configurationfrom thrift.transport import TSocket, TTransportfrom thrift.server import TServerport = 9999cfg_file_name = '/tmp/shop2020.cfg'def main(argv):try:opts, args = getopt(argv,"p:f:", ["port=", "file="])except GetoptError:usage()sys.exit(2)for opt,arg in opts:if opt in ('-p', "--port"):port = arg;elif opt in ('-f', "--file"):cfg_file_name = argstart_server()def start_server():handler = ConfigServerHandler(cfg_file_name)processor = Configuration.Processor(handler)transport = TSocket.TServerSocket(port)tfactory = TTransport.TFramedTransportFactory()pfactory = TBinaryProtocolFactory()server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)print "Starting config server with config params, port "+ str(port)+" file "+cfg_file_nameserver.serve()print "Server functioning"def usage():print 'Usage: ConfigServer.py -p <port_to_run> -f <config_file_path> or ConfigServer.py --port=<port_to_run> --file=<config_file_path>'if __name__ == '__main__':main(sys.argv[1:])