Skip to content

本地开发指南

Komari 使用了 Go + React 技术栈进行开发。如果您想在本地进行二次开发或调试,可以参考以下步骤:

环境准备

  1. 安装 Git

  2. 安装 Go(建议版本 1.24 及以上)。

  3. 安装 Node.js(建议版本 20 及以上)。

克隆源码

使用 Git 克隆 Komari 源码仓库:

  1. 后端
bash
git clone https://github.com/komari-monitor/komari
  1. 前端
bash
git clone https://github.com/komari-monitor/komari-web
  1. Agent
bash
git clone https://github.com/komari-monitor/komari-agent

构建前端静态文件

Komari 的后端使用了 go-embed 功能将默认主题静态文件打包进二进制文件中。因此,在启动后端服务之前,必须先构建前端静态文件。(或塞一个假的 index.html ,总是要确保 web/public/defaultTheme/dist 目录存在且包含 index.html 文件)

bash
cd komari-web
npm install
npm run build

生成的静态文件位于 dist 目录下,将其复制到后端源码的 web/public/defaultTheme/dist 目录中;同时复制 komari-theme.json,用于后台读取默认主题元数据和可管理配置:

bash
mkdir -p ../komari/web/public/defaultTheme/dist
cp -r dist/* ../komari/web/public/defaultTheme/dist/
cp komari-theme.json ../komari/web/public/defaultTheme/

启动后端服务

bash
cd ../komari
go run main.go server -l localhost:25774

启动 Agent 服务

bash
cd ../komari-agent
go run main.go --disable-auto-update -e http://localhost:25774 -t <Your Token>