Fix some compose panel bugs and reload workers when changed

This commit is contained in:
2026-02-16 13:39:48 +00:00
parent 9ce50a3053
commit 8ca1695fab
7 changed files with 177 additions and 25 deletions

View File

@@ -1,7 +1,18 @@
#!/usr/bin/env python3
"""
Simple file watcher using stat() instead of watchdog (no external deps).
Watches core/ and app/ for changes and restarts ur_gia.
This lightweight watcher can be used when you don't want the `watchdog`
dependency. Configure the directories to watch using the `WATCH_PATHS`
environment variable (comma-separated). Configure which container to restart
using `TARGET_CONTAINER` (defaults to `ur_gia`).
Example:
WATCH_PATHS=/code/core TARGET_CONTAINER=ur_gia
Touching a file under the watched path will trigger a restart of the target
container; e.g. `touch /code/core/__restart__` will cause the watcher to act.
"""
import os
import sys
@@ -27,21 +38,23 @@ def get_mtime(path):
def restart_ur():
"""Restart ur_gia container."""
print(f'[{time.strftime("%H:%M:%S")}] Restarting ur_gia...', flush=True)
result = subprocess.run(
'podman restart ur_gia 2>/dev/null || docker restart ur_gia 2>/dev/null',
shell=True,
capture_output=True,
)
"""Restart target container (defaults to `ur_gia`)."""
target = os.environ.get('TARGET_CONTAINER', 'ur_gia')
print(f'[{time.strftime("%H:%M:%S")}] Restarting {target}...', flush=True)
cmd = f'podman restart {target} 2>/dev/null || docker restart {target} 2>/dev/null'
result = subprocess.run(cmd, shell=True, capture_output=True)
if result.returncode == 0:
print(f'[{time.strftime("%H:%M:%S")}] ur_gia restarted', flush=True)
print(f'[{time.strftime("%H:%M:%S")}] {target} restarted', flush=True)
else:
print(f'[{time.strftime("%H:%M:%S")}] restart failed', flush=True)
def main():
paths = ['/code/GIA/core', '/code/GIA/app']
# In the container the repository is mounted at /code
# Allow overriding watched paths via environment variable `WATCH_PATHS`.
# Default is `/code/core,/code/app`.
paths_env = os.environ.get('WATCH_PATHS', '/code/core,/code/app')
paths = [p.strip() for p in paths_env.split(',') if p.strip()]
last_mtimes = {}
for path in paths: