diff --git a/README.md b/README.md index a45631c..de210af 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,11 @@ Start Claude Code using the router: ccr code ``` +> **Note**: After modifying the configuration file, you need to restart the service for the changes to take effect: +> ```shell +> ccr restart +> ``` + #### Providers The `Providers` array is where you define the different model providers you want to use. Each provider object requires: @@ -413,5 +418,8 @@ A huge thank you to all our sponsors for their generous support! - @*成 - @Z*o - @*琨 +- [@congzhangzh](https://github.com/congzhangzh) +- @*_ + (If your name is masked, please contact me via my homepage email to update it with your GitHub username.) diff --git a/README_zh.md b/README_zh.md index 9b92851..a812ad9 100644 --- a/README_zh.md +++ b/README_zh.md @@ -151,6 +151,11 @@ npm install -g @musistudio/claude-code-router ccr code ``` +> **注意**: 修改配置文件后,需要重启服务使配置生效: +> ```shell +> ccr restart +> ``` + #### Providers `Providers` 数组是您定义要使用的不同模型提供商的地方。每个提供商对象都需要: @@ -408,6 +413,8 @@ jobs: - @*琢 - @*成 - @Z*o +- [@congzhangzh](https://github.com/congzhangzh) +- @*_ (如果您的名字被屏蔽,请通过我的主页电子邮件与我联系,以便使用您的 GitHub 用户名进行更新。) diff --git a/blog/images/wechat_group.jpg b/blog/images/wechat_group.jpg index 938a782..a7ac04b 100644 Binary files a/blog/images/wechat_group.jpg and b/blog/images/wechat_group.jpg differ diff --git a/src/cli.ts b/src/cli.ts index 62476a2..26d004c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -109,6 +109,41 @@ async function main() { case "version": 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."); + break; case "-h": case "help": console.log(HELP_TEXT);