38 lines
986 B
Python
38 lines
986 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
import time
|
|
|
|
from updater.github_client import Settings, run_once
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
)
|
|
logger = logging.getLogger("fromchat.updater.main")
|
|
|
|
|
|
def main() -> None:
|
|
settings = Settings.from_env()
|
|
if not settings.github_token:
|
|
logger.warning(
|
|
"UPDATER_TOKEN is not set (check server .env and updater env_file); "
|
|
"GitHub/Gitea API calls will fail"
|
|
)
|
|
logger.info(
|
|
"FromChat updater started (project=%s, current=%s, interval=%ss)",
|
|
settings.compose_project_dir,
|
|
settings.current_version or "(none)",
|
|
settings.check_interval_seconds,
|
|
)
|
|
while True:
|
|
try:
|
|
run_once(settings)
|
|
except Exception:
|
|
logger.exception("Update check failed")
|
|
time.sleep(settings.check_interval_seconds)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|