mirror of
https://github.com/blw1138/Zordon.git
synced 2026-02-05 13:46:10 +00:00
Speed improvements to launch
This commit is contained in:
13
server.py
13
server.py
@@ -17,7 +17,7 @@ from src.engines.engine_manager import EngineManager
|
||||
from src.render_queue import RenderQueue
|
||||
from src.utilities.config import Config
|
||||
from src.utilities.misc_helper import (get_gpu_info, system_safe_path, current_system_cpu, current_system_os,
|
||||
current_system_os_version, check_for_updates)
|
||||
current_system_os_version, current_system_cpu_brand, check_for_updates)
|
||||
from src.utilities.zeroconf_server import ZeroconfServer
|
||||
from src.version import APP_NAME, APP_VERSION, APP_REPO_NAME, APP_REPO_OWNER
|
||||
|
||||
@@ -93,10 +93,6 @@ def start_server(skip_updates=False) -> int:
|
||||
ServerProxyManager.subscribe_to_listener()
|
||||
DistributedJobManager.subscribe_to_listener()
|
||||
|
||||
# check for updates for render engines if configured or on first launch
|
||||
if Config.update_engines_on_launch or not EngineManager.get_engines():
|
||||
EngineManager.update_all_engines()
|
||||
|
||||
# get hostname
|
||||
local_hostname = socket.gethostname()
|
||||
|
||||
@@ -108,7 +104,7 @@ def start_server(skip_updates=False) -> int:
|
||||
# start zeroconf server
|
||||
ZeroconfServer.configure(f"_{APP_NAME.lower()}._tcp.local.", local_hostname, Config.port_number)
|
||||
ZeroconfServer.properties = {'system_cpu': current_system_cpu(),
|
||||
'system_cpu_brand': cpuinfo.get_cpu_info()['brand_raw'],
|
||||
'system_cpu_brand': current_system_cpu_brand(),
|
||||
'system_cpu_cores': multiprocessing.cpu_count(),
|
||||
'system_os': current_system_os(),
|
||||
'system_os_version': current_system_os_version(),
|
||||
@@ -118,6 +114,11 @@ def start_server(skip_updates=False) -> int:
|
||||
ZeroconfServer.start()
|
||||
logger.info(f"{APP_NAME} Render Server started - Hostname: {local_hostname}")
|
||||
RenderQueue.start() # Start evaluating the render queue
|
||||
|
||||
# check for updates for render engines if configured or on first launch
|
||||
# if Config.update_engines_on_launch or not EngineManager.get_engines():
|
||||
# EngineManager.update_all_engines()
|
||||
|
||||
api_server.join()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
||||
@@ -7,6 +7,7 @@ import shutil
|
||||
import socket
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -139,6 +140,29 @@ def current_system_cpu():
|
||||
# convert all x86 64 to "x64"
|
||||
return platform.machine().lower().replace('amd64', 'x64').replace('x86_64', 'x64')
|
||||
|
||||
def current_system_cpu_brand():
|
||||
"""Fast cross-platform CPU brand string"""
|
||||
if sys.platform.startswith('darwin'): # macOS
|
||||
try:
|
||||
return subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).decode().strip()
|
||||
except Exception:
|
||||
pass
|
||||
elif sys.platform.startswith('win'): # Windows
|
||||
try:
|
||||
return platform.processor() # Often sufficient, or fallback to env var
|
||||
except Exception:
|
||||
pass
|
||||
elif sys.platform.startswith('linux'):
|
||||
try:
|
||||
with open('/proc/cpuinfo') as f:
|
||||
for line in f:
|
||||
if line.startswith('model name'):
|
||||
return line.split(':', 1)[1].strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Ultimate fallback
|
||||
return platform.processor() or 'Unknown CPU'
|
||||
|
||||
def resources_dir():
|
||||
resource_environment_path = os.environ.get('RESOURCEPATH', None)
|
||||
@@ -284,7 +308,11 @@ def get_gpu_info():
|
||||
def get_macos_gpu_info():
|
||||
"""Get GPU info on macOS (works with Apple Silicon)"""
|
||||
try:
|
||||
result = subprocess.run(['system_profiler', 'SPDisplaysDataType', '-json'],
|
||||
if current_system_cpu() == "arm64":
|
||||
# don't bother with system_profiler with Apple ARM - we know its integrated
|
||||
return [{'name': current_system_cpu_brand(), 'memory': 'Integrated'}]
|
||||
|
||||
result = subprocess.run(['system_profiler', 'SPDisplaysDataType', '-detailLevel', 'mini', '-json'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
data = json.loads(result.stdout)
|
||||
|
||||
@@ -296,7 +324,7 @@ def get_gpu_info():
|
||||
'name': display.get('sppci_model', 'Unknown GPU'),
|
||||
'memory': display.get('sppci_vram', 'Integrated'),
|
||||
})
|
||||
return gpus if gpus else [{'name': 'Apple Silicon GPU', 'memory': 'Integrated'}]
|
||||
return gpus if gpus else [{'name': 'Apple GPU', 'memory': 'Integrated'}]
|
||||
except Exception as e:
|
||||
print(f"Failed to get macOS GPU info: {e}")
|
||||
return [{'name': 'Unknown GPU', 'memory': 'Unknown'}]
|
||||
|
||||
Reference in New Issue
Block a user