mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
TEST
This commit is contained in:
1 parent
5b4d1b0aa3
commit
0a2bbc75d8
2 files changed
+38
-17
No files matched your search
@@ -99,7 +99,8 @@ const totalShards = envPositiveInt("FLUXER_TOTAL_SHARDS")
|
||||
const shardsPerProcess = envPositiveInt("FLUXER_SHARDS_PER_PROCESS")
|
||||
?? cfgPositiveInt(shardingCfg, "shardsPerProcess", 1);
|
||||
const respawn = shardingCfg.respawn !== false;
|
||||
const spawnTimeout = cfgPositiveInt(shardingCfg, "spawnTimeout", 30_000);
|
||||
const spawnTimeout = envPositiveInt("FLUXER_SPAWN_TIMEOUT")
|
||||
?? Math.max(300_000, cfgPositiveInt(shardingCfg, "spawnTimeout", 300_000));
|
||||
const spawnDelay = Math.max(0, Number(shardingCfg.spawnDelay) >= 0 ? Number(shardingCfg.spawnDelay) : 5_000);
|
||||
|
||||
const entryFile = fileURLToPath(new URL("./index.mjs", import.meta.url));
|
||||
@@ -148,12 +149,21 @@ process.once("SIGINT", () => shutdown("SIGINT"));
|
||||
process.once("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGPIPE", () => {});
|
||||
|
||||
manager.spawn().then((shards) => {
|
||||
logger.player(
|
||||
`[Sharding] ${shards.size} shard process(es) online — ${totalShards} gateway shard(s), ` +
|
||||
`${shardsPerProcess} per process (respawn ${respawn ? "on" : "off"}).`
|
||||
);
|
||||
}).catch((e) => {
|
||||
logger.error("[Sharding] Spawn failed:", e?.message ?? e);
|
||||
process.exit(1);
|
||||
});
|
||||
const spawnWithRetry = async () => {
|
||||
while (!shuttingDown) {
|
||||
try {
|
||||
const shards = await manager.spawn();
|
||||
logger.player(
|
||||
`[Sharding] ${shards.size} shard process(es) online — ${totalShards} gateway shard(s), ` +
|
||||
`${shardsPerProcess} per process (respawn ${respawn ? "on" : "off"}).`
|
||||
);
|
||||
break;
|
||||
} catch (e) {
|
||||
if (shuttingDown) break;
|
||||
logger.error("[Sharding] Spawn attempt failed:", e?.message ?? e);
|
||||
logger.warn("[Sharding] Retrying manager.spawn() in 15 seconds...");
|
||||
await new Promise((r) => setTimeout(r, 15_000));
|
||||
}
|
||||
}
|
||||
};
|
||||
spawnWithRetry();
|
||||
Reference in new issue
Block a user