diff --git a/src/cli.ts b/src/cli.ts index 2fc9100..d6a4a84 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -74,7 +74,7 @@ async function main() { } break; case "status": - showStatus(); + await showStatus(); break; case "code": if (!isServiceRunning()) { diff --git a/src/index.ts b/src/index.ts index 553a45b..c52ac1a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,7 +56,7 @@ async function run(options: RunOptions = {}) { ); } - const port = options.port || 3456; + const port = config.PORT || 3456; // Save the PID of the background process savePid(process.pid); diff --git a/src/utils/codeCommand.ts b/src/utils/codeCommand.ts index 136335b..1865542 100644 --- a/src/utils/codeCommand.ts +++ b/src/utils/codeCommand.ts @@ -12,7 +12,7 @@ export async function executeCodeCommand(args: string[] = []) { const env = { ...process.env, ANTHROPIC_AUTH_TOKEN: "test", - ANTHROPIC_BASE_URL: `http://127.0.0.1:3456`, + ANTHROPIC_BASE_URL: `http://127.0.0.1:${config.PORT || 3456}`, API_TIMEOUT_MS: "600000", }; diff --git a/src/utils/processCheck.ts b/src/utils/processCheck.ts index 42c40b9..b5b2113 100644 --- a/src/utils/processCheck.ts +++ b/src/utils/processCheck.ts @@ -1,5 +1,6 @@ import { existsSync, readFileSync, writeFileSync } from 'fs'; import { PID_FILE, REFERENCE_COUNT_FILE } from '../constants'; +import { readConfigFile } from '.'; export function incrementReferenceCount() { let count = 0; @@ -70,15 +71,16 @@ export function getServicePid(): number | null { } } -export function getServiceInfo() { +export async function getServiceInfo() { const pid = getServicePid(); const running = isServiceRunning(); + const config = await readConfigFile(); return { running, pid, - port: 3456, - endpoint: 'http://127.0.0.1:3456', + port: config.PORT, + endpoint: `http://127.0.0.1:${config.PORT}`, pidFile: PID_FILE, referenceCount: getReferenceCount() }; diff --git a/src/utils/status.ts b/src/utils/status.ts index c7c3d93..ee05126 100644 --- a/src/utils/status.ts +++ b/src/utils/status.ts @@ -1,7 +1,7 @@ import { getServiceInfo } from './processCheck'; -export function showStatus() { - const info = getServiceInfo(); +export async function showStatus() { + const info = await getServiceInfo(); console.log('\nšŸ“Š Claude Code Router Status'); console.log('═'.repeat(40));