Add Plutonium version checks and scheduled rolling restarts
This commit is contained in:
@@ -3,6 +3,7 @@ import type { Socket } from 'node:dgram';
|
||||
import { config, komodoConfigured, rconConfigured } from '../config.js';
|
||||
import { getServer, setServerField } from '../fleet/servers.js';
|
||||
import { komodoResolveGamePort } from './komodo.js';
|
||||
import { parsePlutoniumRevision } from '../../plutonium.js';
|
||||
|
||||
// Plutonium/CoD RCON is UDP with a 4-byte 0xff prefix. Requests look like
|
||||
// \xff\xff\xff\xffrcon <password> <command>
|
||||
@@ -451,3 +452,14 @@ function positiveCapacity(value: string | undefined): number | null {
|
||||
const count = Number(value);
|
||||
return Number.isInteger(count) && count > 0 ? count : null;
|
||||
}
|
||||
|
||||
/** Query the running process, not the updater's on-disk files. */
|
||||
export async function rconPlutoniumVersion(server: string): Promise<{ revision: number | null; error: string | null }> {
|
||||
const { endpoint } = await endpointFor(server);
|
||||
if (!endpoint) return { revision: null, error: 'No RCON endpoint available.' };
|
||||
const response = await sendRcon(endpoint.host, endpoint.port, 'version');
|
||||
if (!response.ok) return { revision: null, error: response.detail };
|
||||
const body = stripPrefix(response.buf);
|
||||
const revision = body?.trimStart().startsWith('print') ? parsePlutoniumRevision(body) : null;
|
||||
return { revision, error: revision === null ? 'RCON version reply did not identify a Plutonium revision.' : null };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user