mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-04-26 00:06:14 -05:00
feat: make server health_check_port optional
This commit is contained in:
parent
84094ed232
commit
38c6e6ecdf
|
|
@ -64,7 +64,10 @@ const ServerSchema = new Schema<IServer, ServerModel, IServerMethods>({
|
|||
maintenance_mode: Boolean,
|
||||
device: Number,
|
||||
aes_key: String,
|
||||
health_check_port: Number
|
||||
health_check_port: {
|
||||
type: Number,
|
||||
required: false
|
||||
}
|
||||
});
|
||||
|
||||
ServerSchema.plugin(uniqueValidator, { message: '{PATH} already in use.' });
|
||||
|
|
@ -75,9 +78,18 @@ ServerSchema.method('getServerConnectInfo', async function (): Promise<IServerCo
|
|||
throw new Error(`No IP configured for server ${this._id}`);
|
||||
}
|
||||
|
||||
const randomIP = ipList[Math.floor(Math.random() * ipList.length)];
|
||||
|
||||
if (!this.health_check_port) {
|
||||
return {
|
||||
ip: randomIP,
|
||||
port: this.port
|
||||
};
|
||||
}
|
||||
|
||||
const healthCheckTargets = ipList.map(ip => ({
|
||||
host: ip,
|
||||
port: this.health_check_port
|
||||
port: this.health_check_port!
|
||||
}));
|
||||
|
||||
let target: string | undefined;
|
||||
|
|
@ -91,8 +103,6 @@ ServerSchema.method('getServerConnectInfo', async function (): Promise<IServerCo
|
|||
// TODO - Handle this
|
||||
}
|
||||
|
||||
const randomIP = ipList[Math.floor(Math.random() * ipList.length)];
|
||||
|
||||
return {
|
||||
ip: target || randomIP, // * Just use a random IP if nothing responded in time and Hope For The Best:tm:
|
||||
port: this.port
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface IServer {
|
|||
maintenance_mode: boolean;
|
||||
device: number;
|
||||
aes_key: string;
|
||||
health_check_port: number;
|
||||
health_check_port?: number;
|
||||
}
|
||||
|
||||
export interface IServerConnectInfo {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user