mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-20 02:08:12 +00:00
Serverproxy manager (#61)
* Create serverproxy_manager.py * Replace use of direct RenderServerProxy with ServerProxyManager method
This commit is contained in:
@@ -18,8 +18,8 @@ import psutil
|
||||
import yaml
|
||||
from flask import Flask, request, render_template, send_file, after_this_request, Response, redirect, url_for, abort
|
||||
|
||||
from src.api.server_proxy import RenderServerProxy
|
||||
from src.api.add_job_helpers import handle_uploaded_project_files, process_zipped_project, create_render_jobs
|
||||
from src.api.serverproxy_manager import ServerProxyManager
|
||||
from src.distributed_job_manager import DistributedJobManager
|
||||
from src.engines.core.base_worker import string_to_status, RenderStatus
|
||||
from src.engines.engine_manager import EngineManager
|
||||
@@ -211,7 +211,7 @@ def make_job_ready(job_id):
|
||||
for child_key in found_job.children.keys():
|
||||
child_id = child_key.split('@')[0]
|
||||
hostname = child_key.split('@')[-1]
|
||||
RenderServerProxy(hostname).request_data(f'job/{child_id}/make_ready')
|
||||
ServerProxyManager.get_proxy_for_hostname(hostname).request_data(f'job/{child_id}/make_ready')
|
||||
found_job.status = RenderStatus.NOT_STARTED
|
||||
RenderQueue.save_state()
|
||||
return found_job.json(), 200
|
||||
|
||||
16
src/api/serverproxy_manager.py
Normal file
16
src/api/serverproxy_manager.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from src.api.server_proxy import RenderServerProxy
|
||||
|
||||
|
||||
class ServerProxyManager:
|
||||
|
||||
server_proxys = {}
|
||||
|
||||
@classmethod
|
||||
def get_proxy_for_hostname(cls, hostname):
|
||||
found_proxy = cls.server_proxys.get(hostname)
|
||||
if not found_proxy:
|
||||
new_proxy = RenderServerProxy(hostname)
|
||||
new_proxy.start_background_update()
|
||||
cls.server_proxys[hostname] = new_proxy
|
||||
found_proxy = new_proxy
|
||||
return found_proxy
|
||||
Reference in New Issue
Block a user