|
| 1 | +# Copyright 2016 Internap. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import argparse |
| 16 | +import logging |
| 17 | + |
| 18 | +from almanach import config |
| 19 | +from almanach.api import AlmanachApi |
| 20 | +from almanach.collector import AlmanachCollector |
| 21 | + |
| 22 | + |
| 23 | +def run(): |
| 24 | + parser = argparse.ArgumentParser() |
| 25 | + parser.add_argument("service", help="Service to execute: 'api' or 'collector'", choices=["api", "collector"]) |
| 26 | + parser.add_argument("config_file", help="Config file path") |
| 27 | + parser.add_argument("--logging", help="Logger configuration") |
| 28 | + args = parser.parse_args() |
| 29 | + |
| 30 | + config.read(args.config_file) |
| 31 | + |
| 32 | + if args.service == "api": |
| 33 | + almanach_api = AlmanachApi() |
| 34 | + almanach_api.run() |
| 35 | + else: |
| 36 | + almanach_collector = AlmanachCollector() |
| 37 | + almanach_collector.run() |
| 38 | + |
| 39 | + if args.logging: |
| 40 | + logging.config.fileConfig(args.logging, disable_existing_loggers=False) |
| 41 | + |
| 42 | + |
| 43 | +if __name__ == "__main__": |
| 44 | + run() |
0 commit comments