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

chore: name cortex processes #983

Merged
merged 2 commits into from
Aug 6, 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
1 change: 1 addition & 0 deletions cortex-js/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependenciesSpinner.succeed(
);

process.removeAllListeners('warning');
process.title = 'Cortex CLI Command Process';

async function bootstrap() {
let telemetryUseCase: TelemetryUsecases | null = null;
Expand Down
7 changes: 2 additions & 5 deletions cortex-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
defaultCortexJsPort,
} from '@/infrastructure/constants/cortex';
import { getApp } from './app';
import chalk from 'chalk';
import { CortexUsecases } from './usecases/cortex/cortex.usecases';

/**
Expand All @@ -20,10 +19,8 @@ export async function start(host?: string, port?: number) {
await app.listen(sPort, sHost);
const cortexUsecases = await app.resolve(CortexUsecases);
await cortexUsecases.startCortex();
console.log(chalk.blue(`Started server at http://${sHost}:${sPort}`));
console.log(
chalk.blue(`API Playground available at http://${sHost}:${sPort}/api`),
);
console.log(`Started server at http://${sHost}:${sPort}`);
console.log(`API Playground available at http://${sHost}:${sPort}/api`);
} catch {
console.error(`Failed to start server. Is port ${port} in use?`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class CortexCommand extends CommandRunner {

this.host = options?.address || configApiServerHost || defaultCortexJsHost;
this.port = options?.port || configApiServerPort || defaultCortexJsPort;
if(this.host === 'localhost') {
if (this.host === 'localhost') {
this.host = '127.0.0.1';
}
this.enginePort =
Expand Down Expand Up @@ -122,9 +122,7 @@ export class CortexCommand extends CommandRunner {
const isServerOnline = await this.cortexUseCases.isAPIServerOnline();
if (isServerOnline) {
console.log(
chalk.blue(
`Server is already running at http://${this.configHost}:${this.configPort}. Please use 'cortex stop' to stop the server.`,
),
`Server is already running at http://${this.configHost}:${this.configPort}. Please use 'cortex stop' to stop the server.`,
);
process.exit(0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SubCommand } from 'nest-commander';
import { BaseCommand } from './base.command';
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases';
import { FileManagerService } from '../services/file-manager/file-manager.service';

@SubCommand({
name: 'stop',
Expand Down
13 changes: 6 additions & 7 deletions cortex-js/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
defaultCortexJsPort,
} from '@/infrastructure/constants/cortex';
import { getApp } from './app';
import chalk from 'chalk';

process.title = 'Cortex API Server';

async function bootstrap() {
// getting port from env
Expand All @@ -12,12 +13,10 @@ async function bootstrap() {
const app = await getApp(host, Number(port));
try {
await app.listen(port, host);
console.log(chalk.blue(`Started server at http://${host}:${port}`));
console.log(
chalk.blue(`API Playground available at http://${host}:${port}/api`),
);
} catch {
console.error(`Failed to start server. Is port ${port} in use?`);
console.log(`Started server at http://${host}:${port}`);
console.log(`API Playground available at http://${host}:${port}/api`);
} catch (error) {
console.error(`Failed to start server. Is port ${port} in use? ${error}`);
}
}

Expand Down
1 change: 0 additions & 1 deletion cortex-js/src/usecases/cortex/cortex.usecases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ export class CortexUsecases implements BeforeApplicationShutdown {
// for backward compatibility, we didn't have the apiServerHost and apiServerPort in the config file in the past
const apiServerHost = configApiServerHost || defaultCortexJsHost;
const apiServerPort = configApiServerPort || defaultCortexJsPort;
await this.stopCortex();
return fetch(CORTEX_JS_SYSTEM_URL(apiServerHost, apiServerPort), {
method: 'DELETE',
}).catch(() => {});
Expand Down
1 change: 1 addition & 0 deletions cortex-js/src/utils/cortex-cpp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cortexCPP from 'cortex-cpp';

process.title = 'Cortex Engine Process (cortex.cpp)';
const port = process.env.CORTEX_CPP_PORT
? parseInt(process.env.CORTEX_CPP_PORT)
: 3929;
Expand Down
Loading