OLD | NEW |
1 # Copyright 2014 The Swarming Authors. All rights reserved. | 1 # Copyright 2014 The Swarming Authors. All rights reserved. |
2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Runs either task_runner.py, bot_main.py or bot_config.py. | 5 """Runs either task_runner.py, bot_main.py or bot_config.py. |
6 | 6 |
7 The imports are done late so if an ImportError occurs, it is localized to this | 7 The imports are done late so if an ImportError occurs, it is localized to this |
8 command only. | 8 command only. |
9 """ | 9 """ |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 def CMDtask_runner(args): | 53 def CMDtask_runner(args): |
54 """Internal command to run a swarming task.""" | 54 """Internal command to run a swarming task.""" |
55 logging_utils.prepare_logging(os.path.join('logs', 'task_runner.log')) | 55 logging_utils.prepare_logging(os.path.join('logs', 'task_runner.log')) |
56 from bot_code import task_runner | 56 from bot_code import task_runner |
57 return task_runner.main(args) | 57 return task_runner.main(args) |
58 | 58 |
59 | 59 |
60 def CMDstart_bot(args): | 60 def CMDstart_bot(args): |
61 """Starts the swarming bot.""" | 61 """Starts the swarming bot.""" |
62 logging_utils.prepare_logging(os.path.join('logs', 'swarming_bot.log')) | 62 logging_utils.prepare_logging(os.path.join('logs', 'swarming_bot.log')) |
63 logging_utils.set_console_level(logging.DEBUG) | |
64 logging.info( | 63 logging.info( |
65 'importing bot_main: %s, %s', THIS_FILE, zip_package.generate_version()) | 64 'importing bot_main: %s, %s', THIS_FILE, zip_package.generate_version()) |
66 from bot_code import bot_main | 65 from bot_code import bot_main |
67 result = bot_main.main(args) | 66 result = bot_main.main(args) |
68 logging.info('bot_main exit code: %d', result) | 67 logging.info('bot_main exit code: %d', result) |
69 return result | 68 return result |
70 | 69 |
71 | 70 |
72 def CMDstart_slave(args): | 71 def CMDstart_slave(args): |
73 """Ill named command that actually sets up the bot then start it.""" | 72 """Ill named command that actually sets up the bot then start it.""" |
74 # TODO(maruel): Rename function. | 73 # TODO(maruel): Rename function. |
75 logging_utils.prepare_logging(os.path.join('logs', 'bot_config.log')) | 74 logging_utils.prepare_logging(os.path.join('logs', 'bot_config.log')) |
76 logging_utils.set_console_level(logging.DEBUG) | |
77 | 75 |
78 parser = optparse.OptionParser() | 76 parser = optparse.OptionParser() |
79 parser.add_option( | 77 parser.add_option( |
80 '--survive', action='store_true', | 78 '--survive', action='store_true', |
81 help='Do not reboot the host even if bot_config.setup_bot() asked to') | 79 help='Do not reboot the host even if bot_config.setup_bot() asked to') |
82 options, args = parser.parse_args(args) | 80 options, args = parser.parse_args(args) |
83 | 81 |
84 try: | 82 try: |
85 from bot_code import bot_main | 83 from bot_code import bot_main |
86 bot_main.setup_bot(options.survive) | 84 bot_main.setup_bot(options.survive) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 with zipfile.ZipFile(THIS_FILE, 'r') as f: | 155 with zipfile.ZipFile(THIS_FILE, 'r') as f: |
158 logging.error('Files in %s:\n%s', THIS_FILE, f.namelist()) | 156 logging.error('Files in %s:\n%s', THIS_FILE, f.namelist()) |
159 return 1 | 157 return 1 |
160 | 158 |
161 print >> sys.stderr, 'Unknown command %s' % cmd | 159 print >> sys.stderr, 'Unknown command %s' % cmd |
162 return 1 | 160 return 1 |
163 | 161 |
164 | 162 |
165 if __name__ == '__main__': | 163 if __name__ == '__main__': |
166 sys.exit(main()) | 164 sys.exit(main()) |
OLD | NEW |