Skip to content

Commit 412f908

Browse files
committed
fix: 修复没有正确的 keepalive
1 parent f40ceb1 commit 412f908

File tree

3 files changed

+25
-44
lines changed

3 files changed

+25
-44
lines changed

assets/js/pwa.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

assets/js/service-worker.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

core/cluster.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ async def sync(self):
499499

500500
await self.clusters.storage_manager.available()
501501
configurations: defaultdict[str, deque[OpenBMCLAPIConfiguration]] = defaultdict(deque)
502+
# default configurations
503+
configurations["default"].append(OpenBMCLAPIConfiguration(
504+
source="default",
505+
concurrency=10, # from bangbang93 openbmclapi configuration
506+
))
507+
# get configurations
502508
for configuration in await asyncio.gather(*(asyncio.create_task(self._get_configuration(cluster)) for cluster in self.clusters.clusters)):
503509
for k, v in configuration.items():
504510
configurations[k].append(v)
@@ -1042,6 +1048,8 @@ async def enable(self):
10421048
}
10431049
}
10441050
, 120)
1051+
except asyncio.CancelledError:
1052+
raise
10451053
except:
10461054
return
10471055
finally:
@@ -1079,13 +1087,21 @@ async def keepalive(self):
10791087
):
10801088
total_counter.hits += counter.hits
10811089
total_counter.bytes += counter.bytes
1082-
result = await self.socket_io.emit(
1083-
"keep-alive", {
1084-
"time": int(time.time() * 1000),
1085-
**asdict(total_counter)
1086-
}
1087-
)
1088-
if result.err or not result.ack:
1090+
result = None
1091+
try:
1092+
result = await self.socket_io.emit(
1093+
"keep-alive", {
1094+
"time": int(time.time() * 1000),
1095+
**asdict(total_counter)
1096+
},
1097+
timeout=10
1098+
)
1099+
except asyncio.CancelledError:
1100+
raise
1101+
except:
1102+
...
1103+
1104+
if result is None or result.err or not result.ack:
10891105
if self.keepalive_error >= 3:
10901106
logger.twarning("cluster.warning.kicked_by_remote", cluster=self.id)
10911107
await self.disable()
@@ -1106,7 +1122,8 @@ async def disable(self, exit: bool = False):
11061122
scheduler.cancel(self.delay_enable_task)
11071123
if self.enabled or self.want_enable:
11081124
result = await self.socket_io.emit(
1109-
"disable"
1125+
"disable",
1126+
timeout=10
11101127
)
11111128
clusters.status.exit()
11121129
if result.err:

0 commit comments

Comments
 (0)