Subversion Repositories SmartDukaan

Rev

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

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