Skip to content

Commit

Permalink
fix: 修复没有正确的 keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiu2b2t committed Jan 17, 2025
1 parent f40ceb1 commit 412f908
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 44 deletions.
22 changes: 0 additions & 22 deletions assets/js/pwa.js

This file was deleted.

14 changes: 0 additions & 14 deletions assets/js/service-worker.js

This file was deleted.

33 changes: 25 additions & 8 deletions core/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ async def sync(self):

await self.clusters.storage_manager.available()
configurations: defaultdict[str, deque[OpenBMCLAPIConfiguration]] = defaultdict(deque)
# default configurations
configurations["default"].append(OpenBMCLAPIConfiguration(
source="default",
concurrency=10, # from bangbang93 openbmclapi configuration
))
# get configurations
for configuration in await asyncio.gather(*(asyncio.create_task(self._get_configuration(cluster)) for cluster in self.clusters.clusters)):
for k, v in configuration.items():
configurations[k].append(v)
Expand Down Expand Up @@ -1042,6 +1048,8 @@ async def enable(self):
}
}
, 120)
except asyncio.CancelledError:
raise
except:
return
finally:
Expand Down Expand Up @@ -1079,13 +1087,21 @@ async def keepalive(self):
):
total_counter.hits += counter.hits
total_counter.bytes += counter.bytes
result = await self.socket_io.emit(
"keep-alive", {
"time": int(time.time() * 1000),
**asdict(total_counter)
}
)
if result.err or not result.ack:
result = None
try:
result = await self.socket_io.emit(
"keep-alive", {
"time": int(time.time() * 1000),
**asdict(total_counter)
},
timeout=10
)
except asyncio.CancelledError:
raise
except:
...

if result is None or result.err or not result.ack:
if self.keepalive_error >= 3:
logger.twarning("cluster.warning.kicked_by_remote", cluster=self.id)
await self.disable()
Expand All @@ -1106,7 +1122,8 @@ async def disable(self, exit: bool = False):
scheduler.cancel(self.delay_enable_task)
if self.enabled or self.want_enable:
result = await self.socket_io.emit(
"disable"
"disable",
timeout=10
)
clusters.status.exit()
if result.err:
Expand Down

0 comments on commit 412f908

Please sign in to comment.