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

Ability to disable federation.

parent f7dd2ede
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,8 @@ api_port=8008 ...@@ -23,6 +23,8 @@ api_port=8008
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
...@@ -23,6 +23,8 @@ api_port=8008 ...@@ -23,6 +23,8 @@ api_port=8008
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
...@@ -23,6 +23,8 @@ api_port=8008 ...@@ -23,6 +23,8 @@ api_port=8008
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
...@@ -95,8 +95,11 @@ with app.app_context(): ...@@ -95,8 +95,11 @@ with app.app_context():
# Run sync job only in SYNC NODE mode # Run sync job only in SYNC NODE mode
if node_type == NodeType.SYNC: if node_type == NodeType.SYNC:
sync_job = SyncJob(config, logger, app) if config.get("enable_federation") == "false":
sync_job.start() logger.info("Node synchronization disabled")
else:
sync_job = SyncJob(config, logger, app)
sync_job.start()
atexit.register(shutdown) atexit.register(shutdown)
logger.info("Engine API server initialized.") logger.info("Engine API server initialized.")
......
...@@ -150,6 +150,9 @@ class ApiService(): ...@@ -150,6 +150,9 @@ class ApiService():
if not data.log_source: if not data.log_source:
data.log_source = self.config.get("host_id") data.log_source = self.config.get("host_id")
if self.config.get("enable_federation") == "false":
return
# Main Node: Alway log entry, independed of the source # Main Node: Alway log entry, independed of the source
# Sync Node: Only log entry when it's coming from an active source # Sync Node: Only log entry when it's coming from an active source
if self.node_type == NodeType.MAIN or \ if self.node_type == NodeType.MAIN or \
...@@ -205,6 +208,9 @@ class ApiService(): ...@@ -205,6 +208,9 @@ class ApiService():
clock_info = ClockInfo(body.engine_source, body.current_playlist, body.current_schedule, body.next_schedule) clock_info = ClockInfo(body.engine_source, body.current_playlist, body.current_schedule, body.next_schedule)
clock_info.merge() clock_info.merge()
if self.config.get("enable_federation") == "false":
return
# Main Node: Push to Sync Node, if enabled # Main Node: Push to Sync Node, if enabled
if self.node_type == NodeType.MAIN and self.sync_host and self.api_clockinfo: if self.node_type == NodeType.MAIN and self.sync_host and self.api_clockinfo:
try: try:
...@@ -215,7 +221,7 @@ class ApiService(): ...@@ -215,7 +221,7 @@ class ApiService():
else: else:
self.logger.error("HTTP %s | Error while pushing clock info to sync-node: " % (r.status_code, str(r.json()))) self.logger.error("HTTP %s | Error while pushing clock info to sync-node: " % (r.status_code, str(r.json())))
except Exception as e: except Exception as e:
self.logger.error("Error while putting clock info to sync-node API '%s'!\n%s" % (api_url, str(e))) self.logger.error("Error while putting clock info to sync-node API '%s'!\n%s" % (api_url, str(e)))
def set_default_source(self, source_number): def set_default_source(self, source_number):
...@@ -287,6 +293,9 @@ class ApiService(): ...@@ -287,6 +293,9 @@ class ApiService():
if not data.log_source: if not data.log_source:
data.log_source = self.host_id data.log_source = self.host_id
if self.config.get("enable_federation") == "false":
return
# Main Node: Alway log entry, independed of the source # Main Node: Alway log entry, independed of the source
# Sync Node: Only log entry when it's coming from an active source # Sync Node: Only log entry when it's coming from an active source
if self.node_type == NodeType.MAIN or \ if self.node_type == NodeType.MAIN or \
......
...@@ -73,7 +73,7 @@ class SyncJob(threading.Thread): ...@@ -73,7 +73,7 @@ class SyncJob(threading.Thread):
def run(self): def run(self):
""" """
Starts the Job. Starts the Job.
""" """
self.synchronize() self.synchronize()
while not self.exit_event.wait(self.sync_interval): while not self.exit_event.wait(self.sync_interval):
try: try:
......
...@@ -23,6 +23,8 @@ api_port=8010 ...@@ -23,6 +23,8 @@ api_port=8010
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
...@@ -23,6 +23,8 @@ api_port=8008 ...@@ -23,6 +23,8 @@ api_port=8008
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
...@@ -23,6 +23,8 @@ api_port=8009 ...@@ -23,6 +23,8 @@ api_port=8009
[federation] [federation]
enable_federation="false"
# Defines the engine number id for identification of record sources. Default values are: # Defines the engine number id for identification of record sources. Default values are:
# #
# 1 ... Engine 1 (main node) # 1 ... Engine 1 (main node)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment