Subversion Repositories SmartDukaan

Rev

Rev 621 | Rev 1248 | Go to most recent revision | Details | Compare with Previous | 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.helpers.impl.HelperServiceHandler import HelperServiceHandler
12
from shop2020.thriftpy.utils import HelperService
13
 
14
 
15
host_name = 'localhost'
16
port = '9008'
17
 
18
def main():
19
    #get the config client
20
    try:
21
        config_client = ConfigClient()
755 rajveer 22
        host_name = config_client.get_property('helper_service_server_host')
23
        port = config_client.get_property('helper_service_server_port')
353 ashish 24
    except:
25
        #error while spawning the config server
26
        host_name = 'localhost'
27
        port = '9008'
28
 
29
    handler = HelperServiceHandler()
30
    processor = HelperService.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 HelperService at, port "+ str(port)+" host "+host_name
36
    server.serve()
37
    print "Server functioning"
38
 
39
 
40
if __name__ == '__main__':
41
    main()