Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
130 ashish 1
'''
2
Created on 04-May-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
7
from shop2020.thriftpy.model.v1.user import UserContextService
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.user.impl.UserContextSerivceHandler import UserContextServiceHandler
12
 
13
 
14
host_name = 'localhost'
15
port = '9000'
16
 
17
def main():
18
    #get the config client
19
    try:
20
        config_client = ConfigClient()
21
        host_name = config_client.get_property('user_service_server_host')
22
        port = config_client.get_property('user_service_server_port')
23
    except:
24
        #error while spawning the config server
25
        host_name = 'localhost'
26
        port = '9000'
27
 
28
    handler = UserContextServiceHandler()
29
    processor = UserContextService.Processor(handler)
30
    transport = TSocket.TServerSocket(port)
31
    tfactory = TTransport.TFramedTransportFactory()
32
    pfactory = TBinaryProtocolFactory()
33
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
34
    print "Starting UserService at, port "+ str(port)+" host "+host_name
35
    server.serve()
36
    print "Server functioning"
37
 
38
 
39
if __name__ == '__main__':
40
    main()