Fix compile breakage from r336003.
[chromium-blink-merge.git] / testing / legion / run_task.py
blobcb0b90fefd6a6a4004e851a013516fbe8c5a739a
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.
6 """The main task entrypoint."""
8 import argparse
9 import logging
10 import socket
11 import sys
12 import time
14 #pylint: disable=relative-import
15 import common_lib
16 import rpc_server
17 import ssl_util
20 def main():
21 print ' '.join(sys.argv)
22 common_lib.InitLogging()
23 logging.info('Task starting')
25 parser = argparse.ArgumentParser()
26 parser.add_argument('--otp',
27 help='One time token used to authenticate with the host')
28 parser.add_argument('--controller',
29 help='The ip address of the controller machine')
30 parser.add_argument('--idle-timeout', type=int,
31 default=common_lib.DEFAULT_TIMEOUT_SECS,
32 help='The idle timeout for the rpc server in seconds')
33 args, _ = parser.parse_known_args()
35 logging.info(
36 'Registering with registration server at %s using OTP "%s"',
37 args.controller, args.otp)
38 ssl_util.SslRpcServer.Connect(args.controller).RegisterTask(
39 args.otp, common_lib.MY_IP)
41 server = rpc_server.RpcServer(args.controller, args.idle_timeout)
43 server.serve_forever()
44 logging.info('Server shutdown complete')
45 return 0
48 if __name__ == '__main__':
49 sys.exit(main())