Subversion Repositories SmartDukaan

Rev

Rev 755 | Rev 1267 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 ashish 1
'''
2
Created on 26-Aug-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
7
from thrift.transport import TSocket, TTransport
8
from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
9
from thrift.server import TServer
10
from shop2020.payments.impl.PaymentsHandler import PaymentsHandler
11
from shop2020.thriftpy.payments import PaymentService
12
 
13
 
14
 
15
host_name = 'localhost'
1248 chandransh 16
port = 9012
17
dbname = 'payment'
420 ashish 18
 
19
def main():
20
    #get the config client
21
    try:
22
        config_client = ConfigClient()
755 rajveer 23
        host_name = config_client.get_property('payments_service_server_host')
24
        port = config_client.get_property('payments_service_server_port')
420 ashish 25
        pass
26
    except:
27
        #error while spawning the config server
28
        host_name = 'localhost'
1248 chandransh 29
        port = 9012
420 ashish 30
 
1248 chandransh 31
    handler = PaymentsHandler(dbname)
420 ashish 32
    processor = PaymentService.Processor(handler)
33
    transport = TSocket.TServerSocket(port)
34
    tfactory = TTransport.TFramedTransportFactory()
35
    pfactory = TBinaryProtocolFactory()
36
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
37
    print "Starting PaymentsService at, port "+ str(port)+" host "+host_name
38
    server.serve()
39
    print "Server functioning"
40
 
41
 
42
if __name__ == '__main__':
43
    main()