安装与部署
# 下载
从 Github Releases (opens new window) 下载对应平台的二进制文件。
# 启动
./server -c="./config.conf"
1
后台启动:
nohup ./server -c="./config.conf" >> console.log &
1
# 配置文件详解
配置文件采用 INI 格式,支持环境变量替换(${VAR} 或 ${VAR:-default})。以下是完整配置项说明:
# 基础配置
| 参数 | 默认值 | 说明 |
|---|---|---|
data_dir | ./data | 数据目录,存放规则链、组件等运行时数据 |
server | :9090 | HTTP 服务监听地址 |
base_path | (空) | API 路由前缀,用于嵌入模式 |
default_username | admin | 未开启认证时的默认用户名 |
skill_path | ./data/skills | 全局 Skill 存储路径 |
# 运行时配置
| 参数 | 默认值 | 说明 |
|---|---|---|
debug | true | 是否记录节点调试数据 |
max_node_log_size | 40 | 单个节点日志最大条数 |
script_max_execution_time | 5000 | 脚本执行超时时间(毫秒) |
save_run_log | false | 是否持久化规则链执行日志 |
run_log_store_type | bbolt | 执行日志存储后端:bbolt、file、nop |
run_log_retention_count | 0 | 保留最近 N 条日志,0 表示不限制 |
run_log_retention_days | 0 | 保留最近 N 天日志,0 表示不限制 |
share_http_server | true | 复用 HTTP 服务器作为规则引擎节点 |
load_lua_libs | true | 是否加载 Lua 第三方库 |
# HTTP 服务配置
| 参数 | 默认值 | 说明 |
|---|---|---|
allow_cors | true | 是否允许跨域请求 |
read_timeout | 30 | HTTP 读超时(秒) |
write_timeout | 300 | HTTP 写超时(秒),AI 流式输出需要较大值 |
max_body_size | 10 | 最大请求体大小(MB) |
# 日志配置
| 参数 | 默认值 | 说明 |
|---|---|---|
log_file | (空) | 日志文件路径,为空则输出到控制台 |
log_level | info | 日志级别:debug、info、warn、error |
log_max_size | 100 | 单个日志文件最大大小(MB) |
log_max_backups | 5 | 保留的旧日志文件数量 |
log_max_age | 30 | 日志文件保留天数 |
# 安全配置
| 参数 | 默认值 | 说明 |
|---|---|---|
require_auth | false | 是否开启 JWT 认证 |
jwt_secret_key | (内置默认值) | JWT 签名密钥,建议通过环境变量 JWT_SECRET_KEY 设置 |
jwt_expire_time | 43200000 | JWT 过期时间(毫秒),默认 12 小时 |
jwt_issuer | rulego.cc | JWT 签发者 |
cmd_mode | allow | Shell 命令安全模式:allow(白名单)、deny(黑名单) |
cmd_white_list | (内置列表) | 允许执行的 Shell 命令列表 |
cmd_deny_list | (空) | 禁止执行的 Shell 命令列表 |
cmd_deny_args | (空) | 禁止的命令参数模式 |
file_path_white_list | /tmp | 文件节点的路径白名单 |
# 资源映射
# 格式:/url/*filepath=/path/to/file,多个映射用逗号分隔
resource_mapping = /editor/*filepath=./editor,/images/*filepath=./editor/images
1
2
2
# 共享节点池
# 节点池文件,规则链 JSON 格式
node_pool_file = ./node_pool.json
1
2
2
# MCP 配置
[mcp]
enable = true
1
2
2
详细说明参见 MCP 服务。
# MCP 分组配置
[mcp.groups]
# 格式:组名 = 工具列表(逗号分隔,支持 * 通配和 - 排除)
readonly = rules,list_components,get_component_doc
full = *
no-delete = *,-delete_rule_chain
1
2
3
4
5
2
3
4
5
# 全局自定义配置
[global]
# 组件可通过 ${global.xxx} 取值
sqlDriver = mysql
sqlDsn = root:root@tcp(127.0.0.1:3306)/test
# AI Agent LLM 配置
llm_url = https://api.openai.com/v1
llm_api_key = sk-xxx
llm_model = gpt-4o
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 用户配置
[users]
# 格式:username = password[,apiKey]
# apiKey 可选,配置后可通过 apiKey 直接访问接口,无需登录
admin = admin,ak-your-secret-key
user01 = user01
1
2
3
4
5
2
3
4
5
# pprof 配置
[pprof]
enable = false
addr = 0.0.0.0:6060
1
2
3
2
3
# Docker 部署
FROM alpine:latest
COPY server /app/server
COPY config.conf /app/config.conf
COPY editor /app/editor
WORKDIR /app
RUN chmod +x server
EXPOSE 9090
CMD ["./server", "-c=./config.conf"]
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
docker build -t rulego-server .
docker run -d -p 9090:9090 -v ./data:/app/data rulego-server
1
2
2
# 从源码构建
# 标准构建
go build -o server ./cmd/server/
# 带 AI 组件
go build -tags "with_ai" -o server ./cmd/server/
# 带所有可选组件
go build -tags "with_all" -o server ./cmd/server/
# 或逐个指定
go build -tags "with_ai,with_iot,with_etl,with_ci,with_extend" -o server ./cmd/server/
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
可用构建标签:
| 标签 | 说明 |
|---|---|
with_all | 所有可选组件(等同于同时启用下面全部标签) |
with_ai | AI 相关组件(ai/agent 节点、LLM 工具等) |
with_iot | IoT 相关组件 |
with_etl | ETL 数据处理组件 |
with_ci | CI/CD 相关组件 |
with_extend | 扩展组件 |
# 完整配置文件示例
# 数据目录
data_dir = ./data
# 命令白名单
cmd_white_list = cp,scp,mvn,npm,yarn,git,make,cmake,docker,kubectl,helm,ansible,puppet,pytest,python,python3,pip,go,java,dotnet,gcc,g++,ctest
# 是否加载 lua 第三方库
load_lua_libs = true
# http server
server = :9090
# 默认用户
default_username = admin
# 节点调试日志
debug = true
max_node_log_size = 40
# 资源映射
resource_mapping = /editor/*filepath=./editor,/images/*filepath=./editor/images
# 节点池文件
node_pool_file = ./node_pool.json
# 执行日志
save_run_log = false
# 脚本超时
script_max_execution_time = 5000
# 认证
require_auth = false
jwt_secret_key = r6G7qZ8xk9P0y1Q2w3E4r5T6y7U8i9O0pL7z8x9CvBnM3k2l1
jwt_expire_time = 43200000
jwt_issuer = rulego.cc
# MCP
[mcp]
enable = true
# pprof
[pprof]
enable = false
addr = 0.0.0.0:6060
# 全局自定义配置
[global]
sqlDriver = mysql
sqlDsn = root:root@tcp(127.0.0.1:3306)/test
# 用户列表
[users]
admin = admin
user01 = user01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
在 GitHub 上编辑此页 (opens new window)
上次更新: 2026/05/28, 10:36:46