From f46ebdf33c2e3b69e410b541a1ad951190c4dab7 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 17 Jun 2024 15:04:58 +0700 Subject: [PATCH] fix: cortex serve should run in attached mode by default --- cortex-js/src/app.module.ts | 2 ++ .../infrastructure/commanders/serve.command.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cortex-js/src/app.module.ts b/cortex-js/src/app.module.ts index 34df5bffd..947d7af7d 100644 --- a/cortex-js/src/app.module.ts +++ b/cortex-js/src/app.module.ts @@ -26,6 +26,7 @@ import { ModelsController } from './infrastructure/controllers/models.controller import { ThreadsController } from './infrastructure/controllers/threads.controller'; import { StatusController } from './infrastructure/controllers/status.controller'; import { ProcessController } from './infrastructure/controllers/process.controller'; +import { DownloadManagerModule } from './download-manager/download-manager.module'; @Module({ imports: [ @@ -48,6 +49,7 @@ import { ProcessController } from './infrastructure/controllers/process.controll FileManagerModule, TelemetryModule, UtilModule, + DownloadManagerModule, ], controllers: [ AssistantsController, diff --git a/cortex-js/src/infrastructure/commanders/serve.command.ts b/cortex-js/src/infrastructure/commanders/serve.command.ts index ee1200967..842c3d99e 100644 --- a/cortex-js/src/infrastructure/commanders/serve.command.ts +++ b/cortex-js/src/infrastructure/commanders/serve.command.ts @@ -12,7 +12,7 @@ import { ServeStopCommand } from './sub-commands/serve-stop.command'; type ServeOptions = { address?: string; port?: number; - attach: boolean; + detach: boolean; }; @SubCommand({ @@ -36,7 +36,7 @@ export class ServeCommand extends CommandRunner { private async startServer( host: string, port: number, - options: ServeOptions = { attach: true }, + options: ServeOptions = { detach: false }, ) { const serveProcess = spawn( 'node', @@ -50,11 +50,11 @@ export class ServeCommand extends CommandRunner { CORTEX_JS_PORT: port.toString(), NODE_ENV: 'production', }, - stdio: options?.attach ? 'inherit' : 'ignore', + stdio: options?.detach ? 'ignore' : 'inherit', detached: true, }, ); - if (!options?.attach) { + if (options?.detach) { serveProcess.unref(); console.log('Started server at http://%s:%d', host, port); } @@ -77,12 +77,12 @@ export class ServeCommand extends CommandRunner { } @Option({ - flags: '-a, --attach', - description: 'Attach to interactive chat session', + flags: '-d, --detach', + description: 'Run the server in detached mode', defaultValue: false, - name: 'attach', + name: 'detach', }) - parseAttach() { + parseDetach() { return true; } }