Subversion Repositories SmartDukaan

Rev

Rev 1249 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
115 ashish 1
'''
2
Created on 06-Apr-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.model.v1.order.impl.OrderServiceHandler import OrderServiceHandler
7
from shop2020.thriftpy.model.v1.order import TransactionService
8
from thrift.transport import TSocket, TTransport
9
from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
10
from thrift.server import TServer
11
from shop2020.config.client.ConfigClient import ConfigClient
12
 
13
host_name = 'localhost'
14
port = '9002'
15
 
16
def main():
17
    try:
18
        config_client = ConfigClient()
19
        host_name = config_client.get_property('transaction_service_server_host')
20
        port = config_client.get_property('transaction_service_server_port')
21
    except:
22
        #error while spawning the config server
23
        host_name = 'localhost'
24
        port = '9002'
25
 
26
    handler = OrderServiceHandler()
27
    processor = TransactionService.Processor(handler)
28
    transport = TSocket.TServerSocket(port)
29
    tfactory = TTransport.TFramedTransportFactory()
30
    pfactory = TBinaryProtocolFactory()
31
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
32
    print "Starting Transaction Service at, port "+ str(port)+" host "+host_name
33
    server.serve()
34
    print "Server functioning"
35
 
36
 
37
 
38
if __name__ == '__main__':
39
    main()