rajendrajaiswal | 318533f | 2020-03-09 15:41:41 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 2 | import logging.config |
| 3 | import os |
| 4 | import sys |
rajendrajaiswal | 6a61ad8 | 2019-12-16 14:24:02 +0000 | [diff] [blame] | 5 | import time |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 6 | |
rajendrajaiswal | 6a61ad8 | 2019-12-16 14:24:02 +0000 | [diff] [blame] | 7 | import schedule |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 8 | import yaml |
| 9 | |
| 10 | from app_config import pnfconfig |
rajendrajaiswal | 6a61ad8 | 2019-12-16 14:24:02 +0000 | [diff] [blame] | 11 | from pnf import PNF |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 12 | |
| 13 | log_file_path = os.path.join(os.path.dirname(__file__), 'app_config/logger_config.yaml') |
| 14 | with open(log_file_path, 'r') as f: |
| 15 | log_cfg = yaml.safe_load(f.read()) |
| 16 | logging.config.dictConfig(log_cfg) |
| 17 | logger = logging.getLogger('dev') |
rajendrajaiswal | 6a61ad8 | 2019-12-16 14:24:02 +0000 | [diff] [blame] | 18 | |
| 19 | if __name__ == "__main__": |
| 20 | try: |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 21 | schedule.every(pnfconfig.ROP).seconds.do(PNF.pm_job) |
| 22 | logger.info('Starting PM scheduling job') |
rajendrajaiswal | 6a61ad8 | 2019-12-16 14:24:02 +0000 | [diff] [blame] | 23 | while True: |
| 24 | schedule.run_pending() |
| 25 | time.sleep(1) |
| 26 | except Exception as error: |
efiacor | e6e9e79 | 2020-07-10 14:58:50 +0100 | [diff] [blame^] | 27 | logger.debug(error) |
| 28 | sys.exit(1) |