mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-01-30 06:12:06 +00:00
fix restart error
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
import { run } from "./utils";
|
||||
import { run, restartService } from "./utils";
|
||||
import { showStatus } from "./utils/status";
|
||||
import { executeCodeCommand, PresetConfig } from "./utils/codeCommand";
|
||||
import {
|
||||
@@ -430,39 +430,7 @@ async function main() {
|
||||
console.log(`claude-code-router version: ${version}`);
|
||||
break;
|
||||
case "restart":
|
||||
// Stop the service if it's running
|
||||
try {
|
||||
const pid = parseInt(readFileSync(PID_FILE, "utf-8"));
|
||||
process.kill(pid);
|
||||
cleanupPidFile();
|
||||
if (existsSync(REFERENCE_COUNT_FILE)) {
|
||||
try {
|
||||
fs.unlinkSync(REFERENCE_COUNT_FILE);
|
||||
} catch (e) {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
}
|
||||
console.log("claude code router service has been stopped.");
|
||||
} catch (e) {
|
||||
console.log("Service was not running or failed to stop.");
|
||||
cleanupPidFile();
|
||||
}
|
||||
|
||||
// Start the service again in the background
|
||||
console.log("Starting claude code router service...");
|
||||
const cliPath = join(__dirname, "cli.js");
|
||||
const startProcess = spawn("node", [cliPath, "start"], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
});
|
||||
|
||||
startProcess.on("error", (error) => {
|
||||
console.error("Failed to start service:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
startProcess.unref();
|
||||
console.log("✅ Service started successfully in the background.");
|
||||
await restartService();
|
||||
break;
|
||||
case "-h":
|
||||
case "help":
|
||||
|
||||
@@ -238,7 +238,7 @@ export const restartService = async () => {
|
||||
|
||||
// Start the service again in the background
|
||||
console.log("Starting claude code router service...");
|
||||
const cliPath = path.join(__dirname, "../cli.js");
|
||||
const cliPath = path.join(__dirname, "cli.js");
|
||||
const startProcess = spawn("node", [cliPath, "start"], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
|
||||
Reference in New Issue
Block a user