Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
412 ashish 1
'''
2
Created on 05-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.logistics.service.impl.LogisticsServiceHandler import LogisticsServiceHandler
11
from shop2020.thriftpy.logistics import LogisticsService
12
 
13
 
14
host_name = 'localhost'
15
port = '9011'
16
 
17
def main():
18
    #get the config client
19
    try:
20
        config_client = ConfigClient()
21
        host_name = config_client.get_property('logistics_service_hostname')
22
        port = config_client.get_property('logistics_service_port')
23
        pass
24
    except:
25
        #error while spawning the config server
26
        host_name = 'localhost'
27
        port = '9011'
28
 
29
    handler = LogisticsServiceHandler()
30
    processor = LogisticsService.Processor(handler)
31
    transport = TSocket.TServerSocket(port)
32
    tfactory = TTransport.TFramedTransportFactory()
33
    pfactory = TBinaryProtocolFactory()
34
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
35
    print "Starting LogisticsService at, port "+ str(port)+" host "+host_name
36
    server.serve()
37
    print "Server functioning"
38
 
39
 
40
if __name__ == '__main__':
41
    main()