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
+30
-9
No files matched your search
@@ -99,7 +99,8 @@ const totalShards = envPositiveInt("FLUXER_TOTAL_SHARDS")
|
|||||||
const shardsPerProcess = envPositiveInt("FLUXER_SHARDS_PER_PROCESS")
|
const shardsPerProcess = envPositiveInt("FLUXER_SHARDS_PER_PROCESS")
|
||||||
?? cfgPositiveInt(shardingCfg, "shardsPerProcess", 1);
|
?? cfgPositiveInt(shardingCfg, "shardsPerProcess", 1);
|
||||||
const respawn = shardingCfg.respawn !== false;
|
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 spawnDelay = Math.max(0, Number(shardingCfg.spawnDelay) >= 0 ? Number(shardingCfg.spawnDelay) : 5_000);
|
||||||
|
|
||||||
const entryFile = fileURLToPath(new URL("./index.mjs", import.meta.url));
|
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.once("SIGTERM", () => shutdown("SIGTERM"));
|
||||||
process.on("SIGPIPE", () => {});
|
process.on("SIGPIPE", () => {});
|
||||||
|
|
||||||
manager.spawn().then((shards) => {
|
const spawnWithRetry = async () => {
|
||||||
|
while (!shuttingDown) {
|
||||||
|
try {
|
||||||
|
const shards = await manager.spawn();
|
||||||
logger.player(
|
logger.player(
|
||||||
`[Sharding] ${shards.size} shard process(es) online — ${totalShards} gateway shard(s), ` +
|
`[Sharding] ${shards.size} shard process(es) online — ${totalShards} gateway shard(s), ` +
|
||||||
`${shardsPerProcess} per process (respawn ${respawn ? "on" : "off"}).`
|
`${shardsPerProcess} per process (respawn ${respawn ? "on" : "off"}).`
|
||||||
);
|
);
|
||||||
}).catch((e) => {
|
break;
|
||||||
logger.error("[Sharding] Spawn failed:", e?.message ?? e);
|
} catch (e) {
|
||||||
process.exit(1);
|
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();
|
||||||
+14
-3
@@ -383,7 +383,6 @@ class Remix {
|
|||||||
`[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.`
|
`[Startup] Sharding child attached — ${ShardingUtils.describeSharding(client)}.`
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
logger.error(
|
logger.error(
|
||||||
"[Startup] FATAL: running under a ShardingManager but the sharding attach failed:",
|
"[Startup] FATAL: running under a ShardingManager but the sharding attach failed:",
|
||||||
e?.message
|
e?.message
|
||||||
@@ -391,15 +390,27 @@ class Remix {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let attempt = 0;
|
||||||
|
while (true) {
|
||||||
|
attempt++;
|
||||||
|
try {
|
||||||
await client.login(config.token);
|
await client.login(config.token);
|
||||||
if (this.shardUtil) {
|
if (this.shardUtil) {
|
||||||
try { this.shardUtil.notifyReady(); }
|
try { this.shardUtil.notifyReady(); }
|
||||||
catch (e) { logger.warn("[Startup] Sharding ready report failed:", e?.message); }
|
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 => {
|
startLogin().catch(e => {
|
||||||
logger.error("[Startup] Login failed:", e?.message ?? e);
|
logger.error("[Startup] Unhandled login loop error:", e?.message ?? e);
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user