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();
|
||||
+18
-7
@@ -383,7 +383,6 @@ class Remix {
|
||||
`[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.`
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
logger.error(
|
||||
"[Startup] FATAL: running under a ShardingManager but the sharding attach failed:",
|
||||
e?.message
|
||||
@@ -391,15 +390,27 @@ class Remix {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
await client.login(config.token);
|
||||
if (this.shardUtil) {
|
||||
try { this.shardUtil.notifyReady(); }
|
||||
catch (e) { logger.warn("[Startup] Sharding ready report failed:", e?.message); }
|
||||
|
||||
let attempt = 0;
|
||||
while (true) {
|
||||
attempt++;
|
||||
try {
|
||||
await client.login(config.token);
|
||||
if (this.shardUtil) {
|
||||
try { this.shardUtil.notifyReady(); }
|
||||
catch (e) { logger.warn("[Startup] Sharding ready report failed:", e?.message); }
|
||||
}
|
||||
break;
|
||||
} catch (err) {
|
||||
const msg = err?.message ?? String(err);
|
||||
logger.error(`[Startup] Login attempt ${attempt} failed: ${msg}`);
|
||||
logger.warn("[Startup] Gateway connection error. Retrying in 10s...");
|
||||
await new Promise(r => setTimeout(r, 10_000));
|
||||
}
|
||||
}
|
||||
};
|
||||
startLogin().catch(e => {
|
||||
logger.error("[Startup] Login failed:", e?.message ?? e);
|
||||
process.exit(1);
|
||||
logger.error("[Startup] Unhandled login loop error:", e?.message ?? e);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user