fix ccr start error

This commit is contained in:
musistudio
2025-12-26 13:33:17 +08:00
parent 18654b60ce
commit dba5116069

View File

@@ -14,7 +14,7 @@ import { writeFileSync, existsSync, readFileSync } from "fs";
import { checkForUpdates, performUpdate } from "./update"; import { checkForUpdates, performUpdate } from "./update";
import { version } from "../../package.json"; import { version } from "../../package.json";
import { spawn } from "child_process"; import { spawn } from "child_process";
import { cleanupPidFile } from "./processCheck"; import {cleanupPidFile, isServiceRunning} from "./processCheck";
// Function to interpolate environment variables in config values // Function to interpolate environment variables in config values
const interpolateEnvVars = (obj: any): any => { const interpolateEnvVars = (obj: any): any => {
@@ -180,6 +180,11 @@ export const initConfig = async () => {
}; };
export const run = async (args: string[] = []) => { export const run = async (args: string[] = []) => {
const isRunning = isServiceRunning()
if (isRunning) {
console.log('claude-code-router server is running');
return;
}
const server = await getServer(); const server = await getServer();
// Save the PID of the background process // Save the PID of the background process
writeFileSync(PID_FILE, process.pid.toString()); writeFileSync(PID_FILE, process.pid.toString());