from __future__ import annotations
import os
+import sys
from pathlib import Path
from typing import TYPE_CHECKING
+from .config import KresConfig
from .constants import RUN_DIR
+from .controller import SupervisordController
+from .controller.errors import ControllerError
from .logging import get_logger
if TYPE_CHECKING:
_config_paths = [Path(file).absolute() for file in args.config]
# TODO(amrazek): load/parse/validate configuration here
+ config = KresConfig()
# TODO(amrazek): set logging level, target, ...
# TODO(amrazek): use 'rundir' from configuration
logger.debug("Changing working directory to '%s'", RUN_DIR)
os.chdir(RUN_DIR)
+
+ try:
+ controller = SupervisordController(args, config)
+ controller.write_config()
+ controller.exec()
+ except ControllerError as e:
+ logger.critical(e)
+ sys.exit(1)