Subversion Repositories SmartDukaan

Rev

Rev 3252 | Rev 3915 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3252 Rev 3537
Line 25... Line 25...
25
    except KeyError:
25
    except KeyError:
26
        environment = "DEV"
26
        environment = "DEV"
27
    
27
    
28
    cfg_file_name = os.path.dirname(os.path.realpath(__file__)) + '/resources/shop2020.cfg'
28
    cfg_file_name = os.path.dirname(os.path.realpath(__file__)) + '/resources/shop2020.cfg'
29
    
29
    
-
 
30
    host = "localhost"
30
    port = 9999
31
    port = 9999
31
    for opt,arg in opts:
32
    for opt,arg in opts:
32
        if opt in ('-p', "--port"):
33
        if opt in ('-p', "--port"):
33
            port = arg;
34
            port = arg;
34
        elif opt in ('-f', "--file"):
35
        elif opt in ('-f', "--file"):
35
            cfg_file_name = arg
36
            cfg_file_name = arg
36
        elif opt in ('-e', "--env"):
37
        elif opt in ('-e', "--env"):
37
            environment = arg
38
            environment = arg
38
    
39
    
39
    start_server(cfg_file_name, port, environment)
40
    start_server(cfg_file_name, host, port, environment)
40
    
41
    
41
def start_server(filename, port, environment):
42
def start_server(filename, host, port, environment):
42
    handler = ConfigServerHandler(filename, environment)
43
    handler = ConfigServerHandler(filename, environment)
43
    processor = Configuration.Processor(handler)
44
    processor = Configuration.Processor(handler)
44
    transport = TSocket.TServerSocket(port)
45
    transport = TSocket.TServerSocket(host, port)
45
    tfactory = TTransport.TFramedTransportFactory()
46
    tfactory = TTransport.TFramedTransportFactory()
46
    pfactory = TBinaryProtocolFactory()
47
    pfactory = TBinaryProtocolFactory()
47
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
48
    server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
48
    print "Starting config server with config params, port "+ str(port)+" file "+ filename
49
    print "Starting config server with config params, port "+ str(port)+" file "+ filename
49
    server.serve()
50
    server.serve()