From 55100daed4def9c4647800d072aa61cfc52c4049 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Mon, 27 Jan 2025 09:51:51 -0500 Subject: [PATCH] feat: try catch restart --- api/src/unraid-api/cli/restart.command.ts | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/api/src/unraid-api/cli/restart.command.ts b/api/src/unraid-api/cli/restart.command.ts index 0812e217e..538e4dc2c 100644 --- a/api/src/unraid-api/cli/restart.command.ts +++ b/api/src/unraid-api/cli/restart.command.ts @@ -11,14 +11,27 @@ export class RestartCommand extends CommandRunner { } async run(_): Promise { - const { stderr, stdout } = await execa(PM2_PATH, ['restart', ECOSYSTEM_PATH, '--update-env']); - if (stderr) { - this.logger.error(stderr); + try { + const { stderr, stdout } = await execa(PM2_PATH, [ + 'restart', + ECOSYSTEM_PATH, + '--update-env', + ]); + if (stderr) { + this.logger.error(stderr); + process.exit(1); + } + if (stdout) { + this.logger.info(stdout); + } + } catch (error) { + if (error instanceof Error) { + this.logger.error(error.message); + } else { + this.logger.error('Unknown error occurred'); + } process.exit(1); } - if (stdout) { - this.logger.info(stdout); - } process.exit(0); } }