Webpublisher - webserver ip is configurable

In some cases webserver needs to listen on specific ip (because of Docker)
This commit is contained in:
Petr Kalis 2021-08-24 11:08:44 +02:00
parent eabfc473ac
commit a3f1067364
4 changed files with 12 additions and 4 deletions

View file

@ -1,5 +1,6 @@
import threading
import asyncio
import os
from aiohttp import web
@ -110,7 +111,9 @@ class WebServerThread(threading.Thread):
""" Starts runner and TCPsite """
self.runner = web.AppRunner(self.manager.app)
await self.runner.setup()
self.site = web.TCPSite(self.runner, 'localhost', self.port)
host_ip = os.environ.get("WEBSERVER_HOST_IP") or 'localhost'
log.info("host_ip:: {}".format(os.environ.get("WEBSERVER_HOST_IP")))
self.site = web.TCPSite(self.runner, host_ip, self.port)
await self.site.start()
def stop(self):

View file

@ -19,7 +19,7 @@ from .webpublish_routes import (
from openpype.api import get_system_settings
SERVER_URL = "http://172.17.0.1:8079" # machine is not listening on localhost
# SERVER_URL = "http://172.17.0.1:8079" # machine is not listening on localhost
log = PypeLogger().get_logger("webserver_gui")
@ -129,7 +129,8 @@ def reprocess_failed(upload_dir):
}}
)
continue
server_url = "{}/api/webpublish/batch".format(SERVER_URL)
server_url = "{}/api/webpublish/batch".format(
os.environ["OPENPYPE_WEBSERVER_URL"])
with open(batch_url) as f:
data = json.loads(f.read())

View file

@ -79,7 +79,10 @@ class WebServerModule(PypeModule, ITrayService):
self.server_manager.on_stop_callbacks.append(
self.set_service_failed_icon
)
webserver_url = "http://localhost:{}".format(self.port)
# in a case that webserver should listen on specific ip (webpublisher)
self.log.info("module host_ip:: {}".format(os.environ.get("WEBSERVER_HOST_IP")))
host_ip = os.environ.get("WEBSERVER_HOST_IP") or 'localhost'
webserver_url = "http://{}:{}".format(host_ip, self.port)
os.environ["OPENPYPE_WEBSERVER_URL"] = webserver_url
@staticmethod

View file

@ -40,6 +40,7 @@ Deploy OP build distribution (Openpype Igniter) on an OS of your choice.
```sh
#!/usr/bin/env bash
export OPENPYPE_DEBUG=3
export WEBSERVER_HOST_IP=localhost
export FTRACK_BOT_API_KEY=YOUR_API_KEY
export PYTHONDONTWRITEBYTECODE=1
export OPENPYPE_MONGO=YOUR_MONGODB_CONNECTION