Subversion Repositories SmartDukaan

Rev

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