Subversion Repositories SmartDukaan

Rev

Rev 115 | Rev 1267 | Go to most recent revision | Details | Compare with Previous | 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'
1249 chandransh 14
port = 9002
15
dbname = 'transaction' 
115 ashish 16
 
17
def main():
18
    try:
19
        config_client = ConfigClient()
20
        host_name = config_client.get_property('transaction_service_server_host')
21
        port = config_client.get_property('transaction_service_server_port')
22
    except:
23
        #error while spawning the config server
24
        host_name = 'localhost'
1249 chandransh 25
        port = 9002
115 ashish 26
 
1249 chandransh 27
    handler = OrderServiceHandler(dbname)
115 ashish 28
    processor = TransactionService.Processor(handler)
29
    transport = TSocket.TServerSocket(port)
30
    tfactory = TTransport.TFramedTransportFactory()
31
    pfactory = TBinaryProtocolFactory()
32
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
33
    print "Starting Transaction Service at, port "+ str(port)+" host "+host_name
34
    server.serve()
35
    print "Server functioning"
36
 
37
 
38
 
39
if __name__ == '__main__':
40
    main()