mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: forced restarting on commands
This commit is contained in:
@@ -7,6 +7,4 @@ import { stop } from '@app/cli/commands/stop';
|
||||
export const restart = async () => {
|
||||
await stop();
|
||||
await start();
|
||||
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user