41 lines
921 B
Python
41 lines
921 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
from app.config import ConfigError, load_config
|
|
from app.scheduler import run_forever
|
|
|
|
logger = logging.getLogger("uptime_monitor")
|
|
|
|
|
|
def setup_logging() -> None:
|
|
logging.basicConfig(
|
|
level=os.environ.get("LOG_LEVEL", "INFO"),
|
|
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
stream=sys.stdout,
|
|
)
|
|
|
|
|
|
def main() -> None:
|
|
setup_logging()
|
|
config_path = os.environ.get("CONFIG_PATH", "/config/config.yaml")
|
|
|
|
try:
|
|
cfg = load_config(config_path)
|
|
except ConfigError as e:
|
|
logger.error("configuration error: %s", e)
|
|
sys.exit(1)
|
|
|
|
logger.info(
|
|
"loaded %d endpoint(s) from %s; interval=%ss, immediate recheck on failure enabled",
|
|
len(cfg.endpoints), config_path, cfg.check.interval_seconds,
|
|
)
|
|
|
|
run_forever(cfg)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|