| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | # Copyright 2020 ArctosLabs Scandinavia AB |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | import argparse |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 18 | import logging |
| 19 | import sys |
| 20 | |
| 21 | from osm_pla.config.config import Config |
| 22 | from osm_pla.server.server import Server |
| 23 | |
| 24 | |
| 25 | def main(): |
| garciadeblas | 20fc3b7 | 2022-11-14 00:48:32 +0100 | [diff] [blame] | 26 | parser = argparse.ArgumentParser(prog="osm-policy-agent") |
| 27 | parser.add_argument("--config-file", nargs="?", help="PLA configuration file") |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 28 | args = parser.parse_args() |
| 29 | cfg = Config(args.config_file) |
| 30 | |
| 31 | root = logging.getLogger() |
| garciadeblas | 20fc3b7 | 2022-11-14 00:48:32 +0100 | [diff] [blame] | 32 | root.setLevel(logging.getLevelName(cfg.get("global", "loglevel"))) |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 33 | ch = logging.StreamHandler(sys.stdout) |
| garciadeblas | 20fc3b7 | 2022-11-14 00:48:32 +0100 | [diff] [blame] | 34 | ch.setLevel(logging.getLevelName(cfg.get("global", "loglevel"))) |
| 35 | formatter = logging.Formatter( |
| 36 | "%(asctime)s - %(name)s - %(levelname)s - %(message)s", "%m/%d/%Y %I:%M:%S %p" |
| 37 | ) |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 38 | ch.setFormatter(formatter) |
| 39 | root.addHandler(ch) |
| 40 | |
| 41 | log = logging.getLogger(__name__) |
| 42 | log.info("Starting PLA Server...") |
| 43 | |
| Mark Beierl | 7cedba1 | 2023-05-10 21:35:27 -0400 | [diff] [blame] | 44 | server = Server(cfg) |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 45 | server.run() |
| 46 | |
| 47 | |
| garciadeblas | 20fc3b7 | 2022-11-14 00:48:32 +0100 | [diff] [blame] | 48 | if __name__ == "__main__": |
| magnussonl | 2b0e2d7 | 2020-02-04 10:52:46 +0100 | [diff] [blame] | 49 | main() |