feat: try catch restart

This commit is contained in:
Eli Bosley
2025-01-27 09:51:51 -05:00
parent b9d9105e3e
commit 55100daed4

View File

@@ -11,14 +11,27 @@ export class RestartCommand extends CommandRunner {
}
async run(_): Promise<void> {
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);
}
}