Subversion Repositories SmartDukaan

Rev

Rev 3537 | Rev 3915 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 05-Aug-2010

@author: ashish
'''
from shop2020.config.client.ConfigClient import ConfigClient
from thrift.transport import TSocket, TTransport
from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory
from thrift.server import TServer
from shop2020.logistics.service.impl.LogisticsServiceHandler import LogisticsServiceHandler
from shop2020.thriftpy.logistics import LogisticsService


host_name = 'localhost'
port = 9011
dbname='logistics'
db_hostname='localhost'

def main():
    #get the config client
    try:
        config_client = ConfigClient()
        host_name = config_client.get_property('logistics_service_server_host')
        port = int(config_client.get_property('logistics_service_server_port'))
        dbname = config_client.get_property('logistics_service_dbname')
        db_hostname = config_client.get_property('logistics_service_db_hostname')
    except:
        #error while spawning the config server
        host_name = 'localhost'
        port = 9011
        dbname='logistics'
        db_hostname = 'localhost'
    
    handler = LogisticsServiceHandler(dbname, db_hostname)
    processor = LogisticsService.Processor(handler)
    transport = TSocket.TServerSocket(port=port)
    tfactory = TTransport.TFramedTransportFactory()
    pfactory = TBinaryProtocolFactory()
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
    print "Starting LogisticsService at, port "+ str(port)+" host "+host_name
    server.serve()
    print "Server functioning"
    

if __name__ == '__main__':
    main()