support configuring the port
This commit is contained in:
@@ -74,7 +74,7 @@ async function main() {
|
||||
}
|
||||
break;
|
||||
case "status":
|
||||
showStatus();
|
||||
await showStatus();
|
||||
break;
|
||||
case "code":
|
||||
if (!isServiceRunning()) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
};
|
||||
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user