From 3279aef9e8f197a08c10ec6507587e4e232fb977 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 6 Aug 2024 17:14:03 +0700 Subject: [PATCH 1/2] chore: name cortex processes --- cortex-js/src/command.ts | 1 + cortex-js/src/infrastructure/commanders/serve-stop.command.ts | 1 - cortex-js/src/main.ts | 2 ++ cortex-js/src/usecases/cortex/cortex.usecases.ts | 1 - cortex-js/src/utils/cortex-cpp.ts | 1 + 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cortex-js/src/command.ts b/cortex-js/src/command.ts index 72de34dcb..b8921ba70 100644 --- a/cortex-js/src/command.ts +++ b/cortex-js/src/command.ts @@ -13,6 +13,7 @@ dependenciesSpinner.succeed( ); process.removeAllListeners('warning'); +process.title = 'Cortex Command Executor'; async function bootstrap() { let telemetryUseCase: TelemetryUsecases | null = null; diff --git a/cortex-js/src/infrastructure/commanders/serve-stop.command.ts b/cortex-js/src/infrastructure/commanders/serve-stop.command.ts index 3fa96be9e..ea9039a4d 100644 --- a/cortex-js/src/infrastructure/commanders/serve-stop.command.ts +++ b/cortex-js/src/infrastructure/commanders/serve-stop.command.ts @@ -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', diff --git a/cortex-js/src/main.ts b/cortex-js/src/main.ts index 988e55426..542e1a91f 100644 --- a/cortex-js/src/main.ts +++ b/cortex-js/src/main.ts @@ -5,6 +5,8 @@ import { import { getApp } from './app'; import chalk from 'chalk'; +process.title = 'Cortex API Server'; + async function bootstrap() { // getting port from env const host = process.env.CORTEX_JS_HOST || defaultCortexJsHost; diff --git a/cortex-js/src/usecases/cortex/cortex.usecases.ts b/cortex-js/src/usecases/cortex/cortex.usecases.ts index 400c76163..01bf1ed09 100644 --- a/cortex-js/src/usecases/cortex/cortex.usecases.ts +++ b/cortex-js/src/usecases/cortex/cortex.usecases.ts @@ -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(() => {}); diff --git a/cortex-js/src/utils/cortex-cpp.ts b/cortex-js/src/utils/cortex-cpp.ts index 3efd755dd..79f1aa70c 100644 --- a/cortex-js/src/utils/cortex-cpp.ts +++ b/cortex-js/src/utils/cortex-cpp.ts @@ -1,5 +1,6 @@ import * as cortexCPP from 'cortex-cpp'; +process.title = 'Cortex Engine Server'; const port = process.env.CORTEX_CPP_PORT ? parseInt(process.env.CORTEX_CPP_PORT) : 3929; From 9aea092994e80e52747cf66b9643c80ccfecef59 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 6 Aug 2024 17:19:26 +0700 Subject: [PATCH 2/2] chore: remove chalk blue text --- cortex-js/src/command.ts | 2 +- cortex-js/src/index.ts | 7 ++----- .../commanders/cortex-command.commander.ts | 6 ++---- cortex-js/src/main.ts | 11 ++++------- cortex-js/src/utils/cortex-cpp.ts | 2 +- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cortex-js/src/command.ts b/cortex-js/src/command.ts index b8921ba70..37aa2a77a 100644 --- a/cortex-js/src/command.ts +++ b/cortex-js/src/command.ts @@ -13,7 +13,7 @@ dependenciesSpinner.succeed( ); process.removeAllListeners('warning'); -process.title = 'Cortex Command Executor'; +process.title = 'Cortex CLI Command Process'; async function bootstrap() { let telemetryUseCase: TelemetryUsecases | null = null; diff --git a/cortex-js/src/index.ts b/cortex-js/src/index.ts index 4d31b2eeb..c383a5417 100644 --- a/cortex-js/src/index.ts +++ b/cortex-js/src/index.ts @@ -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'; /** @@ -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?`); } diff --git a/cortex-js/src/infrastructure/commanders/cortex-command.commander.ts b/cortex-js/src/infrastructure/commanders/cortex-command.commander.ts index ddc24d2d2..98746894c 100644 --- a/cortex-js/src/infrastructure/commanders/cortex-command.commander.ts +++ b/cortex-js/src/infrastructure/commanders/cortex-command.commander.ts @@ -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 = @@ -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); } diff --git a/cortex-js/src/main.ts b/cortex-js/src/main.ts index 542e1a91f..19c3e4d74 100644 --- a/cortex-js/src/main.ts +++ b/cortex-js/src/main.ts @@ -3,7 +3,6 @@ import { defaultCortexJsPort, } from '@/infrastructure/constants/cortex'; import { getApp } from './app'; -import chalk from 'chalk'; process.title = 'Cortex API Server'; @@ -14,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}`); } } diff --git a/cortex-js/src/utils/cortex-cpp.ts b/cortex-js/src/utils/cortex-cpp.ts index 79f1aa70c..efa28adbd 100644 --- a/cortex-js/src/utils/cortex-cpp.ts +++ b/cortex-js/src/utils/cortex-cpp.ts @@ -1,6 +1,6 @@ import * as cortexCPP from 'cortex-cpp'; -process.title = 'Cortex Engine Server'; +process.title = 'Cortex Engine Process (cortex.cpp)'; const port = process.env.CORTEX_CPP_PORT ? parseInt(process.env.CORTEX_CPP_PORT) : 3929;