mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	* fix(ml): Resolve IPv6 startup crash and healthcheck failure Fixes #13782 * fix(ml): updated the fix to use the std lib * Apply code formatting to __main__.py
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import os
 | 
						|
import signal
 | 
						|
import subprocess
 | 
						|
from ipaddress import ip_address
 | 
						|
from pathlib import Path
 | 
						|
 | 
						|
from .config import log, non_prefixed_settings, settings
 | 
						|
 | 
						|
if source_ref := os.getenv("IMMICH_SOURCE_REF"):
 | 
						|
    log.info(f"Initializing Immich ML [{source_ref}]")
 | 
						|
else:
 | 
						|
    log.info("Initializing Immich ML")
 | 
						|
 | 
						|
module_dir = Path(__file__).parent
 | 
						|
 | 
						|
bind_host = non_prefixed_settings.immich_host
 | 
						|
if ip_address(bind_host).version == 6:
 | 
						|
    bind_host = f"[{bind_host}]"
 | 
						|
bind_address = f"{bind_host}:{non_prefixed_settings.immich_port}"
 | 
						|
 | 
						|
try:
 | 
						|
    with subprocess.Popen(
 | 
						|
        [
 | 
						|
            "python",
 | 
						|
            "-m",
 | 
						|
            "gunicorn",
 | 
						|
            "immich_ml.main:app",
 | 
						|
            "-k",
 | 
						|
            "immich_ml.config.CustomUvicornWorker",
 | 
						|
            "-c",
 | 
						|
            module_dir / "gunicorn_conf.py",
 | 
						|
            "-b",
 | 
						|
            bind_address,
 | 
						|
            "-w",
 | 
						|
            str(settings.workers),
 | 
						|
            "-t",
 | 
						|
            str(settings.worker_timeout),
 | 
						|
            "--log-config-json",
 | 
						|
            module_dir / "log_conf.json",
 | 
						|
            "--keep-alive",
 | 
						|
            str(settings.http_keepalive_timeout_s),
 | 
						|
            "--graceful-timeout",
 | 
						|
            "10",
 | 
						|
        ],
 | 
						|
    ) as cmd:
 | 
						|
        cmd.wait()
 | 
						|
except KeyboardInterrupt:
 | 
						|
    cmd.send_signal(signal.SIGINT)
 | 
						|
exit(cmd.returncode)
 |