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 (#22387)
* 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
This commit is contained in:
		
							parent
							
								
									075436a5d1
								
							
						
					
					
						commit
						51150a3ed1
					
				@ -1,6 +1,7 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import signal
 | 
					import signal
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					from ipaddress import ip_address
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .config import log, non_prefixed_settings, settings
 | 
					from .config import log, non_prefixed_settings, settings
 | 
				
			||||||
@ -12,6 +13,11 @@ else:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
module_dir = Path(__file__).parent
 | 
					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:
 | 
					try:
 | 
				
			||||||
    with subprocess.Popen(
 | 
					    with subprocess.Popen(
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
@ -24,7 +30,7 @@ try:
 | 
				
			|||||||
            "-c",
 | 
					            "-c",
 | 
				
			||||||
            module_dir / "gunicorn_conf.py",
 | 
					            module_dir / "gunicorn_conf.py",
 | 
				
			||||||
            "-b",
 | 
					            "-b",
 | 
				
			||||||
            f"{non_prefixed_settings.immich_host}:{non_prefixed_settings.immich_port}",
 | 
					            bind_address,
 | 
				
			||||||
            "-w",
 | 
					            "-w",
 | 
				
			||||||
            str(settings.workers),
 | 
					            str(settings.workers),
 | 
				
			||||||
            "-t",
 | 
					            "-t",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
 | 
					from ipaddress import ip_address
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -7,6 +8,7 @@ port = os.getenv("IMMICH_PORT", 3003)
 | 
				
			|||||||
host = os.getenv("IMMICH_HOST", "0.0.0.0")
 | 
					host = os.getenv("IMMICH_HOST", "0.0.0.0")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
host = "localhost" if host == "0.0.0.0" else host
 | 
					host = "localhost" if host == "0.0.0.0" else host
 | 
				
			||||||
 | 
					host = f"[{host}]" if ip_address(host).version == 6 else host
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    response = requests.get(f"http://{host}:{port}/ping", timeout=2)
 | 
					    response = requests.get(f"http://{host}:{port}/ping", timeout=2)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user