fix(striker-ui-api): add force option to shutdown server

main
Tsu-ba-me 1 year ago
parent 20ae35758a
commit 7bb98ba95f
  1. 11
      striker-ui-api/src/lib/request_handlers/command/buildPowerHandler.ts
  2. 1
      striker-ui-api/src/types/BuildPowerHandlerFunction.d.ts

@ -49,8 +49,10 @@ const MAP_TO_POWER_JOB_PARAMS_BUILDER: Record<
job_name: 'set_power::off',
job_title: 'job_0332',
}),
stopserver: ({ uuid } = {}) => ({
job_command: `${SERVER_PATHS.usr.sbin['anvil-shutdown-server'].self} --server-uuid '${uuid}'`,
stopserver: ({ force, uuid } = {}) => ({
job_command: `${
SERVER_PATHS.usr.sbin['anvil-shutdown-server'].self
} --server-uuid '${uuid}'${force ? ' --immediate' : ''}`,
job_description: 'job_0343',
job_name: 'set_power::server::off',
job_title: 'job_0342',
@ -76,8 +78,11 @@ export const buildPowerHandler: (
(task) => async (request, response) => {
const {
params: { uuid },
query: { force: rForce },
} = request;
const force = sanitize(rForce, 'boolean');
try {
if (uuid) {
assert(
@ -92,7 +97,7 @@ export const buildPowerHandler: (
}
try {
await queuePowerJob(task, { uuid });
await queuePowerJob(task, { force, uuid });
} catch (error) {
stderr(`Failed to ${task} ${uuid ?? LOCAL}; CAUSE: ${error}`);

@ -9,6 +9,7 @@ type PowerTask =
type PowerJobParams = Omit<JobParams, 'file' | 'line'>;
type BuildPowerJobParamsOptions = {
force?: boolean;
isStopServers?: boolean;
uuid?: string;
};

Loading…
Cancel
Save