OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
Marc-Antoine Ruel (Google)
2015/01/30 21:58:38
Saved 19 lines, or 28% of lines, not too bad. :)
I
Mike Meade
2015/02/03 01:18:07
Acknowledged.
| |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 """The main client_controller code. | |
6 | |
7 This code is the main entry point for the client machines and handles | |
8 registering with the host server and running the local RPC server. | |
9 """ | |
10 | |
11 import argparse | |
12 import logging | |
13 import socket | |
14 import sys | |
15 import time | |
16 | |
17 #pylint: disable=relative-import | |
18 import client_rpc_server | |
19 import common_lib | |
20 import discovery_server | |
21 | |
22 | |
23 def main(): | |
24 common_lib.InitLogging() | |
25 common_lib.LogCommandLine() | |
26 logging.info('Client controller starting') | |
27 | |
28 parser = argparse.ArgumentParser() | |
29 parser.add_argument('--otp') | |
30 parser.add_argument('--host') | |
31 parser.add_argument('--idle-timeout', type=int) | |
32 args, _ = parser.parse_known_args() | |
33 | |
34 logging.info( | |
35 'Registering with discovery server using OTP %s', args.otp) | |
36 server = discovery_server.DiscoveryServer.Connect(args.host).RegisterClient( | |
37 args.otp, common_lib.MY_IP) | |
38 | |
39 server = client_rpc_server.RPCServer() | |
40 server.AddAuthorizedAddress(args.host) | |
41 if args.idle_timeout: | |
42 server.SetIdleTimeout(args.idle_timeout) | |
43 | |
44 server.serve_forever() | |
45 return 0 | |
46 | |
47 | |
48 if __name__ == '__main__': | |
49 sys.exit(main()) | |
OLD | NEW |