neural-runner / boot.py
glutamatt's picture
glutamatt HF Staff
deploy: clean rebuild 1774852650
542ca82 verified
#!/usr/bin/env python3
"""
Boot script for HF Space.
Prepares environment before starting services.
"""
import os
import sys
import logging
from pathlib import Path
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='[%(asctime)s] %(levelname)s: %(message)s'
)
logger = logging.getLogger(__name__)
def main():
"""Boot sequence for HF Space."""
logger.info("=" * 60)
logger.info("Neural Runner - Boot Sequence")
logger.info("=" * 60)
# Read git commit hash for log prefixes
git_commit = "unknown"
git_commit_file = Path("/home/user/app/frontend/.git-commit")
if git_commit_file.exists():
try:
git_commit = git_commit_file.read_text().strip()
logger.info(f"✓ Git commit: {git_commit}")
except Exception as e:
logger.warning(f"Failed to read .git-commit: {e}")
else:
logger.warning("⚠️ .git-commit file not found")
# Set git commit as environment variable for all services
os.environ["GIT_COMMIT"] = git_commit
# Start process-compose to run all services (disable TUI for container)
logger.info("Starting services via process-compose...")
os.execvp("process-compose", [
"process-compose",
"-t=false", # Disable TUI (no terminal in container)
"--no-server", # Disable HTTP server (frees port 8080)
"-f", "/home/user/app/process-compose.yaml"
])
if __name__ == "__main__":
main()