feat(config): add configurable default shutdown delay for shutdown actions
This commit is contained in:
+13
-5
@@ -10,7 +10,7 @@ import type { TProtocol } from '../protocol/types.ts';
|
||||
import type { INupstConfig, IUpsConfig } from '../daemon.ts';
|
||||
import type { IActionConfig } from '../actions/base-action.ts';
|
||||
import { ProxmoxAction } from '../actions/proxmox-action.ts';
|
||||
import { UPSD } from '../constants.ts';
|
||||
import { SHUTDOWN, UPSD } from '../constants.ts';
|
||||
|
||||
/**
|
||||
* Thresholds configuration for CLI display
|
||||
@@ -1152,11 +1152,19 @@ export class UpsHandler {
|
||||
if (typeValue === 1) {
|
||||
// Shutdown action
|
||||
action.type = 'shutdown';
|
||||
const defaultShutdownDelay =
|
||||
this.nupst.getDaemon().getConfig().defaultShutdownDelay ?? SHUTDOWN.DEFAULT_DELAY_MINUTES;
|
||||
|
||||
const delayInput = await prompt('Shutdown delay in minutes [5]: ');
|
||||
const delay = parseInt(delayInput, 10);
|
||||
if (delayInput.trim() && !isNaN(delay)) {
|
||||
action.shutdownDelay = delay;
|
||||
const delayInput = await prompt(
|
||||
`Shutdown delay in minutes (leave empty for default ${defaultShutdownDelay}): `,
|
||||
);
|
||||
if (delayInput.trim()) {
|
||||
const delay = parseInt(delayInput, 10);
|
||||
if (isNaN(delay) || delay < 0) {
|
||||
logger.warn('Invalid shutdown delay, using configured default');
|
||||
} else {
|
||||
action.shutdownDelay = delay;
|
||||
}
|
||||
}
|
||||
} else if (typeValue === 2) {
|
||||
// Webhook action
|
||||
|
||||
Reference in New Issue
Block a user