From abd8e099087124933aed0179802fb0c1105f1759 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Wed, 6 Nov 2024 15:21:08 -0500 Subject: [PATCH] fix: forced restarting on commands --- api/src/cli/commands/restart.ts | 2 -- api/src/cli/commands/start.ts | 5 +---- api/src/cli/commands/stop.ts | 5 +---- api/src/cli/index.ts | 11 +++-------- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/api/src/cli/commands/restart.ts b/api/src/cli/commands/restart.ts index 2b5f86936..187fa266f 100644 --- a/api/src/cli/commands/restart.ts +++ b/api/src/cli/commands/restart.ts @@ -7,6 +7,4 @@ import { stop } from '@app/cli/commands/stop'; export const restart = async () => { await stop(); await start(); - - process.exit(0); }; diff --git a/api/src/cli/commands/start.ts b/api/src/cli/commands/start.ts index 043c1a944..b760b747e 100644 --- a/api/src/cli/commands/start.ts +++ b/api/src/cli/commands/start.ts @@ -5,14 +5,11 @@ import { join } from 'node:path'; /** * Start a new API process. */ -export const start = async (exit = false) => { +export const start = async () => { cliLogger.info('Starting unraid-api with command', `${PM2_PATH} start ${join(import.meta.dirname, 'ecosystem.config.json')} --update-env`); execSync(`${PM2_PATH} start ${join(import.meta.dirname, '../../', 'ecosystem.config.json')} --update-env`, { env: process.env, stdio: 'inherit', }); - if (exit) { - process.exit(0); - } }; diff --git a/api/src/cli/commands/stop.ts b/api/src/cli/commands/stop.ts index 26cff6619..3b627632b 100644 --- a/api/src/cli/commands/stop.ts +++ b/api/src/cli/commands/stop.ts @@ -1,9 +1,6 @@ import { PM2_PATH } from '@app/consts'; import { execSync } from 'child_process'; -export const stop = async (exit = false) => { +export const stop = async () => { execSync(`${PM2_PATH} stop unraid-api`, { stdio: 'inherit' }); - if (exit) { - process.exit(0); - } }; diff --git a/api/src/cli/index.ts b/api/src/cli/index.ts index 052fbe27c..f45bc6960 100755 --- a/api/src/cli/index.ts +++ b/api/src/cli/index.ts @@ -27,8 +27,8 @@ export const main = async (...argv: string[]) => { // Only import the command we need when we use it const commands = { - start: import('@app/cli/commands/start').then((pkg) => pkg.start(true)), - stop: import('@app/cli/commands/stop').then((pkg) => pkg.stop(true)), + start: import('@app/cli/commands/start').then((pkg) => pkg.start), + stop: import('@app/cli/commands/stop').then((pkg) => pkg.stop), restart: import('@app/cli/commands/restart').then((pkg) => pkg.restart), logs: async () => execSync(`${PM2_PATH} logs unraid-api --lines 200`, { stdio: 'inherit' }), 'switch-env': import('@app/cli/commands/switch-env').then((pkg) => pkg.switchEnv), @@ -49,10 +49,5 @@ export const main = async (...argv: string[]) => { // Run the command await commandMethod(...argv); - // Allow the process to exit - // Don't exit when we start though - if (!['start', 'restart'].includes(command)) { - // Ensure process is exited - process.exit(0); - } + process.exit(0); };