diff --git a/api/src/cli/commands/status.ts b/api/src/cli/commands/status.ts index b14673f33..f226aecf9 100644 --- a/api/src/cli/commands/status.ts +++ b/api/src/cli/commands/status.ts @@ -1,5 +1,6 @@ +import { PM2_PATH } from '@app/consts'; import { execSync } from 'child_process'; export const status = async () => { - execSync('pm2 status unraid-api', { stdio: 'inherit' }); + execSync(`${PM2_PATH} status unraid-api`, { stdio: 'inherit' }); }; diff --git a/api/src/cli/index.ts b/api/src/cli/index.ts index 41c658cdc..0702fa4cf 100755 --- a/api/src/cli/index.ts +++ b/api/src/cli/index.ts @@ -5,6 +5,7 @@ import { setEnv } from '@app/cli/set-env'; import { env } from '@app/dotenv'; import { getters } from '@app/store'; import { execSync } from 'child_process'; +import { PM2_PATH } from '@app/consts'; const command = mainOptions.command as unknown as string; @@ -31,7 +32,7 @@ export const main = async (...argv: string[]) => { 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 logs unraid-api --lines 200', { stdio: 'inherit' }), + logs: async () => execSync(`${PM2_PATH} logs unraid-api --lines 200`, { stdio: 'inherit' }), 'switch-env': import('@app/cli/commands/switch-env').then((pkg) => pkg.switchEnv), version: import('@app/cli/commands/version').then((pkg) => pkg.version), status: import('@app/cli/commands/status').then((pkg) => pkg.status), diff --git a/api/src/core/utils/pm2/unraid-api-running.ts b/api/src/core/utils/pm2/unraid-api-running.ts index 542132f86..b7fd6b5be 100644 --- a/api/src/core/utils/pm2/unraid-api-running.ts +++ b/api/src/core/utils/pm2/unraid-api-running.ts @@ -5,25 +5,22 @@ export const isUnraidApiRunning = async (): Promise => { pm2.connect(function (err) { if (err) { console.error(err); - reject('Could not connect to pm2'); + reject('Could not connect to pm2'); } pm2.describe('unraid-api', function (err, processDescription) { - console.log(err) + console.log(err); if (err || processDescription.length === 0) { console.log(false); // Service not found or error occurred - resolve(false); + resolve(false); } else { const isOnline = processDescription?.[0]?.pm2_env?.status === 'online'; console.log(isOnline); // Output true if online, false otherwise - resolve(isOnline); + resolve(isOnline); } pm2.disconnect(); - - }); - }); }); };