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."""
14 #pylint: disable=relative-import
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()
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')
48 if __name__
== '__main__':