Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
webserver_cli use only created WebServerManager instead of webserver …
Browse files Browse the repository at this point in the history
…module
  • Loading branch information
iLLiCiTiT committed Aug 24, 2021
1 parent ad5a73d commit ca641cb
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions openpype/modules/webserver/webserver_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def run_webserver(*args, **kwargs):

manager = ModulesManager()
webserver_module = manager.modules_by_name["webserver"]
webserver_module.create_server_manager()
host = os.environ.get("WEBSERVER_HOST_IP")
port = 8079
server_manager = webserver_module.create_new_server_manager(port, host)
webserver_url = server_manager.url

is_webpublish_enabled = False
webpublish_tool = get_system_settings()["modules"].\
Expand All @@ -41,18 +44,18 @@ def run_webserver(*args, **kwargs):

log.debug("is_webpublish_enabled {}".format(is_webpublish_enabled))
if is_webpublish_enabled:
resource = RestApiResource(webserver_module.server_manager,
resource = RestApiResource(server_manager,
upload_dir=kwargs["upload_dir"],
executable=kwargs["executable"])
projects_endpoint = WebpublisherProjectsEndpoint(resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"GET",
"/api/projects",
projects_endpoint.dispatch
)

hiearchy_endpoint = WebpublisherHiearchyEndpoint(resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"GET",
"/api/hierarchy/{project_name}",
hiearchy_endpoint.dispatch
Expand All @@ -61,15 +64,15 @@ def run_webserver(*args, **kwargs):
# triggers publish
webpublisher_task_publish_endpoint = \
WebpublisherBatchPublishEndpoint(resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"POST",
"/api/webpublish/batch",
webpublisher_task_publish_endpoint.dispatch
)

webpublisher_batch_publish_endpoint = \
WebpublisherTaskPublishEndpoint(resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"POST",
"/api/webpublish/task",
webpublisher_batch_publish_endpoint.dispatch
Expand All @@ -78,30 +81,30 @@ def run_webserver(*args, **kwargs):
# reporting
openpype_resource = OpenPypeRestApiResource()
batch_status_endpoint = BatchStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"GET",
"/api/batch_status/{batch_id}",
batch_status_endpoint.dispatch
)

user_status_endpoint = PublishesStatusEndpoint(openpype_resource)
webserver_module.server_manager.add_route(
server_manager.add_route(
"GET",
"/api/publishes/{user}",
user_status_endpoint.dispatch
)

webserver_module.start_server()
server_manager.start_server()
last_reprocessed = time.time()
while True:
if is_webpublish_enabled:
if time.time() - last_reprocessed > 20:
reprocess_failed(kwargs["upload_dir"])
reprocess_failed(kwargs["upload_dir"], webserver_url)
last_reprocessed = time.time()
time.sleep(1.0)


def reprocess_failed(upload_dir):
def reprocess_failed(upload_dir, webserver_url):
# log.info("check_reprocesable_records")
from openpype.lib import OpenPypeMongoConnection

Expand Down Expand Up @@ -129,8 +132,7 @@ def reprocess_failed(upload_dir):
}}
)
continue
server_url = "{}/api/webpublish/batch".format(
os.environ["OPENPYPE_WEBSERVER_URL"])
server_url = "{}/api/webpublish/batch".format(webserver_url)

with open(batch_url) as f:
data = json.loads(f.read())
Expand Down

0 comments on commit ca641cb

Please sign in to comment.