From 7819dccb100d074c68ae3388fc730e9d5ee741e4 Mon Sep 17 00:00:00 2001 From: Spencer Date: Sat, 14 Mar 2026 20:21:31 -0500 Subject: [PATCH] Add self-update on startup via git pull On each restart, CUE pulls the latest code from origin before binding to the port, so deployments just require a service restart. Co-Authored-By: Claude Sonnet 4.6 --- app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app.py b/app.py index 889e828..c215480 100644 --- a/app.py +++ b/app.py @@ -2,6 +2,7 @@ import hashlib import hmac import json import logging +import subprocess import threading from flask import Flask, request, abort @@ -91,6 +92,23 @@ def webhook(): return {"status": "processing", "files": len(changed_files)}, 200 +def _self_update() -> None: + """Pull the latest code from origin before starting.""" + try: + result = subprocess.run( + ["git", "pull", "--ff-only"], + capture_output=True, + text=True, + ) + if result.returncode == 0: + logger.info("Self-update: %s", result.stdout.strip()) + else: + logger.warning("Self-update failed: %s", result.stderr.strip()) + except Exception as exc: + logger.warning("Self-update error: %s", exc) + + if __name__ == "__main__": + _self_update() logger.info("BLIGHT: CUE starting on port %d", config.WEBHOOK_PORT) app.run(host="0.0.0.0", port=config.WEBHOOK_PORT)