Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change port to 1338
Browse files Browse the repository at this point in the history
namchuai committed Aug 5, 2024
1 parent 323a4f3 commit 9615baa
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 0 additions & 1 deletion electron/handlers/native.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ import {
mkdirSync,
} from 'fs'
import { dump } from 'js-yaml'
import os from 'os'

const isMac = process.platform === 'darwin'

25 changes: 21 additions & 4 deletions electron/main.ts
Original file line number Diff line number Diff line change
@@ -58,15 +58,32 @@ Object.assign(console, log.functions)

let cortexService: ChildProcess | undefined = undefined

const cortexJsPort = 1338
const cortexCppPort = 3940
const host = '127.0.0.1'

app
.whenReady()
.then(() => killProcessesOnPort(3929))
.then(() => killProcessesOnPort(1337))
.then(() => killProcessesOnPort(cortexCppPort))
.then(() => killProcessesOnPort(cortexJsPort))
.then(() => {
const appConfiguration = getAppConfigurations()
const janDataFolder = appConfiguration.data_folder

const command = `${cortexPath} -a 127.0.0.1 -p 1337 --dataFolder ${janDataFolder}`
const cortexParams: Record<string, string> = {
'-n': 'jan',
'-a': host,
'-p': cortexJsPort.toString(),
'-ep': cortexCppPort.toString(),
'--dataFolder': janDataFolder,
}

// add cortex parameters to the command
const command = Object.entries(cortexParams).reduce(
(acc, [key, value]) => `${acc} ${key} ${value}`,
`${cortexPath}`
)

log.info('Starting cortex with command:', command)
// init cortex
cortexService = exec(`${command}`, (error, stdout, stderr) => {
@@ -156,7 +173,7 @@ async function stopCortexService() {
async function stopApiServer() {
// this function is not meant to be success. It will throw an error.
try {
await fetch('http://localhost:1337/v1/system', {
await fetch(`http://localhost:${cortexJsPort}/v1/system`, {
method: 'DELETE',
})
} catch (error) {

0 comments on commit 9615baa

Please sign in to comment.