Rev 621 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 15-Jul-2010@author: ashish'''from shop2020.config.client.ConfigClient import ConfigClientfrom shop2020.thriftpy.model.v1.catalog import InventoryServicefrom thrift.transport import TSocket, TTransportfrom thrift.protocol.TBinaryProtocol import TBinaryProtocolFactoryfrom thrift.server import TServerfrom shop2020.model.v1.catalog.impl.InventoryServiceHandler import InventoryServiceHandlerfrom shop2020.helpers.impl.HelperServiceHandler import HelperServiceHandlerfrom shop2020.thriftpy.utils import HelperServicehost_name = 'localhost'port = '9008'def main():#get the config clienttry:config_client = ConfigClient()host_name = config_client.get_property('helper_service_hostname')port = config_client.get_property('helper_service_port')except:#error while spawning the config serverhost_name = 'localhost'port = '9008'handler = HelperServiceHandler()processor = HelperService.Processor(handler)transport = TSocket.TServerSocket(port)tfactory = TTransport.TFramedTransportFactory()pfactory = TBinaryProtocolFactory()server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)print "Starting HelperService at, port "+ str(port)+" host "+host_nameserver.serve()print "Server functioning"if __name__ == '__main__':main()