Rev 3187 | Rev 3539 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 06-Apr-2010@author: ashish'''from shop2020.model.v1.order.impl.OrderServiceHandler import OrderServiceHandlerfrom shop2020.thriftpy.model.v1.order import TransactionServicefrom thrift.transport import TSocket, TTransportfrom thrift.protocol.TBinaryProtocol import TBinaryProtocolFactoryfrom thrift.server import TServerfrom shop2020.config.client.ConfigClient import ConfigClienthost_name = 'localhost'port = 9002dbname = 'transaction'db_hostname='localhost'def main():try:config_client = ConfigClient()host_name = config_client.get_property('transaction_service_server_host')port = config_client.get_property('transaction_service_server_port')dbname = config_client.get_property('transaction_service_dbname')db_hostname = config_client.get_property('transaction_service_db_hostname')except:#error while spawning the config serverhost_name = 'localhost'port = 9002dbname = 'transaction'db_hostname='localhost'handler = OrderServiceHandler(dbname, db_hostname)processor = TransactionService.Processor(handler)transport = TSocket.TServerSocket(host_name, port)tfactory = TTransport.TFramedTransportFactory()pfactory = TBinaryProtocolFactory()server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)print "Starting Transaction Service at, port "+ str(port)+" host "+host_nameserver.serve()print "Server functioning"if __name__ == '__main__':main()