Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cortex serve should run in attached mode by default #711

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cortex-js/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -48,6 +49,7 @@ import { ProcessController } from './infrastructure/controllers/process.controll
FileManagerModule,
TelemetryModule,
UtilModule,
DownloadManagerModule,
],
controllers: [
AssistantsController,
Expand Down
16 changes: 8 additions & 8 deletions cortex-js/src/infrastructure/commanders/serve.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ServeStopCommand } from './sub-commands/serve-stop.command';
type ServeOptions = {
address?: string;
port?: number;
attach: boolean;
detach: boolean;
};

@SubCommand({
Expand All @@ -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',
Expand All @@ -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);
}
Expand All @@ -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;
}
}
Loading