Subversion Repositories SmartDukaan

Rev

Rev 1267 | Rev 3187 | 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'
1248 chandransh 16
port = 9008
17
dbname = 'helper'
353 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('helper_service_server_host')
1248 chandransh 24
        port = int(config_client.get_property('helper_service_server_port'))
1267 chandransh 25
        dbname = config_client.get_property('helper_service_dbname')
353 ashish 26
    except:
27
        #error while spawning the config server
28
        host_name = 'localhost'
1248 chandransh 29
        port = 9008
1402 ankur.sing 30
        dbname = 'helper'
353 ashish 31
 
1248 chandransh 32
    handler = HelperServiceHandler(dbname)
353 ashish 33
    processor = HelperService.Processor(handler)
34
    transport = TSocket.TServerSocket(port)
35
    tfactory = TTransport.TFramedTransportFactory()
36
    pfactory = TBinaryProtocolFactory()
37
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
38
    print "Starting HelperService at, port "+ str(port)+" host "+host_name
39
    server.serve()
40
    print "Server functioning"
41
 
42
 
43
if __name__ == '__main__':
44
    main()