Skip to content
Snippets Groups Projects
Commit 40cac3e3 authored by David Trattnig's avatar David Trattnig
Browse files

Add configurable control host #104

parent 8197c06b
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,10 @@ api_engine_store_clock="http://localhost:8008/api/v1/clock"
# Engine API endpoint to store health information
api_engine_store_health="http://localhost:8008/api/v1/source/health/${ENGINE_NUMBER}"
## ENGINE-CORE ##
# Host and port of the local engine backchannel (Network Socket for e.g. sending track service updates)
api_engine_control_host="localhost:1337"
[scheduler]
# Database settings: Use 'postgresql', 'sqlite' or 'mysql'. In case of SQLite the "db_name" is the name of the file.
db_type="postgresql"
......
......@@ -65,6 +65,10 @@ api_engine_store_clock="http://127.0.0.1:8008/api/v1/clock"
# Engine API endpoint to store health information
api_engine_store_health="http://127.0.0.1:8008/api/v1/source/health/${ENGINE_NUMBER}"
## ENGINE-CORE ##
# Host and port of the local engine backchannel (Network Socket for e.g. sending track service updates)
api_engine_control_host="0.0.0.0:1337"
[scheduler]
# Database settings: Use 'postgresql', 'sqlite' or 'mysql'. In case of SQLite the "db_name" is the name of the file.
db_type="postgresql"
......
......@@ -65,6 +65,10 @@ api_engine_store_clock="http://localhost:8008/api/v1/clock"
# Engine API endpoint to store health information
api_engine_store_health="http://localhost:8008/api/v1/source/health/${ENGINE_NUMBER}"
## ENGINE-CORE ##
# Host and port of the local engine backchannel (Network Socket for e.g. sending track service updates)
api_engine_control_host="localhost:1337"
[scheduler]
# Database settings: Use 'postgresql', 'sqlite' or 'mysql'. In case of SQLite the "db_name" is the name of the file.
db_type="postgresql"
......
......@@ -74,7 +74,6 @@ class SocketControlInterface:
service is primarily utilized to store new playlogs.
"""
PORT = 1337
ACTION_ON_METADATA = "on_metadata"
instance = None
......@@ -98,8 +97,10 @@ class SocketControlInterface:
self.config = AuraConfig.config()
self.logger = logging.getLogger("AuraEngine")
self.event_dispatcher = event_dispatcher
host = "127.0.0.1"
thread = Thread(target=self.run, args=(self.logger, host))
url_parts = self.config.get("api_engine_control_host").split(":")
host = url_parts[0]
port = int(url_parts[1])
thread = Thread(target=self.run, args=(self.logger, host, port))
thread.start()
@staticmethod
......@@ -111,14 +112,14 @@ class SocketControlInterface:
SocketControlInterface.instance = SocketControlInterface(event_dispatcher)
return SocketControlInterface.instance
def run(self, logger, host):
def run(self, logger, host, port):
"""
Starts the socket server
"""
while True:
try:
self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server.bind((host, SocketControlInterface.PORT))
self.server.bind((host, port))
break
except OSError:
wait_time = 2
......@@ -126,9 +127,7 @@ class SocketControlInterface:
self.logger.error(SU.red(msg))
time.sleep(wait_time)
logger.info(
SU.yellow(f"[ECI] Listening at {host}:{SocketControlInterface.PORT}")
)
logger.info(SU.yellow(f"[ECI] Listening at {host}:{port}"))
self.server.listen()
while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment