Subversion Repositories SmartDukaan

Rev

Rev 3537 | Rev 3915 | 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
1277 varun.gupt 15
dbname = 'transaction'
3187 rajveer 16
db_hostname='localhost'
115 ashish 17
 
18
def main():
19
    try:
20
        config_client = ConfigClient()
21
        host_name = config_client.get_property('transaction_service_server_host')
22
        port = config_client.get_property('transaction_service_server_port')
1267 chandransh 23
        dbname = config_client.get_property('transaction_service_dbname')
3187 rajveer 24
        db_hostname = config_client.get_property('transaction_service_db_hostname')
115 ashish 25
    except:
26
        #error while spawning the config server
27
        host_name = 'localhost'
1249 chandransh 28
        port = 9002
1277 varun.gupt 29
        dbname = 'transaction'
3187 rajveer 30
        db_hostname='localhost'
115 ashish 31
 
3187 rajveer 32
    handler = OrderServiceHandler(dbname, db_hostname)
115 ashish 33
    processor = TransactionService.Processor(handler)
3539 chandransh 34
    transport = TSocket.TServerSocket(port=port)
115 ashish 35
    tfactory = TTransport.TFramedTransportFactory()
36
    pfactory = TBinaryProtocolFactory()
37
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
38
    print "Starting Transaction Service at, port "+ str(port)+" host "+host_name
39
    server.serve()
40
    print "Server functioning"
41
 
42
 
43
 
44
if __name__ == '__main__':
45
    main()