OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 6 """The main client_controller code. |
| 7 |
| 8 This code is the main entry point for the client machines and handles |
| 9 registering with the host server and running the local RPC server. |
| 10 """ |
| 11 |
| 12 import argparse |
| 13 import logging |
| 14 import socket |
| 15 import sys |
| 16 import time |
| 17 |
| 18 #pylint: disable=relative-import |
| 19 import client_rpc_server |
| 20 import common_lib |
| 21 |
| 22 |
| 23 def main(): |
| 24 common_lib.PrintCommandLine() |
| 25 common_lib.InitLogging() |
| 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 default=common_lib.DEFAULT_TIMEOUT_SECS) |
| 33 args, _ = parser.parse_known_args() |
| 34 |
| 35 logging.info( |
| 36 'Registering with discovery server at %s using OTP %s', args.host, |
| 37 args.otp) |
| 38 server = common_lib.ConnectToServer(args.host).RegisterClient( |
| 39 args.otp, common_lib.MY_IP) |
| 40 |
| 41 server = client_rpc_server.RPCServer(args.host, args.idle_timeout) |
| 42 |
| 43 server.serve_forever() |
| 44 return 0 |
| 45 |
| 46 |
| 47 if __name__ == '__main__': |
| 48 sys.exit(main()) |
OLD | NEW |