Skip to content

Commit

Permalink
Merge pull request #54 from Sebi94nbg/Fix-non-opening-channel-issue
Browse files Browse the repository at this point in the history
Fix issue with creating channels when all have clients during restart
  • Loading branch information
Sebbo94BY authored Feb 14, 2023
2 parents 7df7b72 + 31534ae commit 30a53f2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions modules/channel_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ def create_minimum_amount_of_channels(self):
)
continue

existing_channels_with_prefix = self.find_channels_by_prefix(name_prefix)

channel_minimum_available_count_diff = len(
self.find_channels_by_prefix(name_prefix)
existing_channels_with_prefix
) - int(self.channel_minimums[name_prefix])

amount_of_channels_to_create = 0
Expand All @@ -247,6 +249,18 @@ def create_minimum_amount_of_channels(self):
)
amount_of_channels_to_create = int(self.channel_minimums[name_prefix])

amount_of_channels_with_clients = 0
for channel in existing_channels_with_prefix:
if int(channel["total_clients"]) > 0:
amount_of_channels_with_clients += 1

if amount_of_channels_with_clients == len(existing_channels_with_prefix):
ChannelManager.logger.info(
"All existing `%s` channels have clients, but there is no empty one. Creating one.",
str(name_prefix),
)
amount_of_channels_to_create = 1

if amount_of_channels_to_create == 0:
ChannelManager.logger.info(
"All necessary `%s` channels exist. Nothing todo.", str(name_prefix)
Expand Down Expand Up @@ -277,7 +291,9 @@ def create_minimum_amount_of_channels(self):
i = 1
while i <= amount_of_channels_to_create:
if i == 1:
channel_properties.append(f"channel_name={name_prefix} {i}")
channel_properties.append(
f"channel_name={name_prefix} {amount_of_channels_with_clients+1}"
)
else:
channel_properties = [
channel_property.replace(
Expand Down

0 comments on commit 30a53f2

Please sign in to comment.