Skip to content

Commit fb154cb

Browse files
committed
feat: 支持yaml配置文件
1 parent b94ea00 commit fb154cb

File tree

11 files changed

+304
-66
lines changed

11 files changed

+304
-66
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
/config.json
2-
/build
2+
/config.yml
3+
/config.yaml
4+
/build
5+
/.DS_Store

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Setup Go
4848
uses: actions/setup-go@v2
4949
with:
50-
go-version: '^1.22.1'
50+
go-version: '^1.23.1'
5151

5252
- name: Build Binary
5353
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/config.json
2+
/config.yml
3+
/config.yaml
24
/build
35
/.DS_Store

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine AS builder
1+
FROM golang:1.23-alpine AS builder
22

33
WORKDIR /build
44

README-zh.md

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,25 @@ Channel Monitor 是一个用于监控OneAPI/NewAPI渠道的工具,它直接读
1919
- [x] 秒级的请求速率限制
2020
- [x] 支持Uptime Kuma, 在测试时Push URL来可视化模型可用性
2121
- [x] 支持更新推送,包括SMTP邮件和Telegram Bot
22+
- [x] 支持JSON和YAML两种配置文件格式
2223

2324

2425
## 安装
2526

2627
### 二进制
2728

28-
[Releases](https://github.com/DullJZ/ChannelMonitor/releases)页面下载最新版本的二进制文件,在同一目录下配置`config.json`后运行即可。建议使用`screen``nohup`等工具后台运行。
29+
[Releases](https://github.com/DullJZ/ChannelMonitor/releases)页面下载最新版本的二进制文件,在同一目录下配置`config.json``config.yaml`后运行即可。建议使用`screen``nohup`等工具后台运行。
2930
注意⚠️:如果你需要使用SQLite数据库,请使用docker方案或自行启用CGO编译。
3031

3132
```bash
3233
mkdir ChannelMonitor && cd ChannelMonitor
3334
wget https://github.com/DullJZ/ChannelMonitor/releases/download/v0.1.0/ChannelMonitor_linux_amd64
3435
chmod +x ChannelMonitor_linux_amd64
35-
# 下载并修改配置文件
36+
# 下载并修改配置文件(选择JSON或YAML格式)
3637
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
37-
nano config.json
38+
# 或使用YAML格式
39+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
40+
nano config.json # 或 nano config.yaml
3841
screen -S ChannelMonitor
3942
./ChannelMonitor_linux_amd64
4043
```
@@ -43,12 +46,16 @@ screen -S ChannelMonitor
4346

4447
```bash
4548
docker pull dulljz/channel-monitor
46-
# 下载并修改配置文件
49+
# 下载并修改配置文件(选择JSON或YAML格式)
4750
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
48-
nano config.json
51+
# 或使用YAML格式
52+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
53+
nano config.json # 或 nano config.yaml
4954
# 如果使用宿主机的数据库,可以简单使用host模式,
5055
# 并使用localhost:3306作为数据库地址
51-
docker run -d --name ChannelMonitor -v ./config.json:/app/config.json -net host dulljz/channel-monitor
56+
docker run -d --name ChannelMonitor -v ./config.json:/app/config.json --net host dulljz/channel-monitor
57+
# 如果使用YAML格式
58+
# docker run -d --name ChannelMonitor -v ./config.yaml:/app/config.yaml --net host dulljz/channel-monitor
5259
# 如果使用SQLite数据库,挂载数据库文件
5360
# docker run -d --name ChannelMonitor -v ./config.json:/app/config.json -v /path/to/database.db:/app/database.db dulljz/channel-monitor
5461
```
@@ -62,6 +69,8 @@ services:
6269
image: dulljz/channel-monitor
6370
volumes:
6471
- ./config.json:/app/config.json
72+
# 或使用YAML格式
73+
# - ./config.yaml:/app/config.yaml
6574
# 如果使用SQLite数据库,挂载数据库文件
6675
# - /path/to/database.db:/app/database.db
6776
# 如果使用宿主机的数据库,可以简单使用host模式,
@@ -70,15 +79,22 @@ services:
7079
```
7180
7281
```bash
73-
# 下载并修改配置文件
82+
# 下载并修改配置文件(选择JSON或YAML格式)
7483
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
75-
nano config.json
84+
# 或使用YAML格式
85+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
86+
nano config.json # 或 nano config.yaml
7687
docker-compose up -d
7788
```
7889

7990
## 配置
8091

81-
配置文件使用同级目录下的`config.json`文件,格式如下:
92+
配置文件可以是同级目录下的`config.json``config.yaml``config.yml`文件,程序会自动按照`config.yaml` -> `config.yml` -> `config.json`的顺序检测并使用可用的配置文件。
93+
94+
### JSON格式
95+
96+
<details>
97+
<summary>点击展开/折叠JSON配置示例</summary>
8298

8399
```json
84100
{
@@ -129,6 +145,61 @@ docker-compose up -d
129145
}
130146
```
131147

148+
</details>
149+
150+
### YAML格式
151+
152+
<details>
153+
<summary>点击展开/折叠YAML配置示例</summary>
154+
155+
```yaml
156+
oneapi_type: oneapi
157+
exclude_channel: [5]
158+
exclude_model:
159+
- advanced-voice
160+
- minimax_s2v-01
161+
- minimax_video-01
162+
- minimax_video-01-live2d
163+
models:
164+
- gpt-3.5-turbo
165+
- gpt-4o
166+
force_models: false
167+
force_inside_models: false
168+
time_period: 1h
169+
max_concurrent: 5
170+
rps: 5
171+
db_type: YOUR_DB_TYPE
172+
db_dsn: YOUR_DB_DSN
173+
do_not_modify_db: false
174+
base_url: http://localhost:3000
175+
system_token: YOUR_SYSTEM_TOKEN
176+
uptime-kuma:
177+
status: disabled
178+
model_url:
179+
gpt-3.5-turbo: https://demo.kuma.pet/api/push/A12n43563?status=up&msg=OK&ping=
180+
gpt-4o: https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping=
181+
channel_url:
182+
"5": https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping=
183+
notification:
184+
smtp:
185+
enabled: false
186+
host: smtp.example.com
187+
port: 25
188+
189+
password: your-password
190+
191+
192+
webhook:
193+
enabled: false
194+
type: telegram
195+
telegram:
196+
chat_id: YOUR_CHAT_ID
197+
retry: 3
198+
secret: YOUR_WEBHOOK_SECRET
199+
```
200+
201+
</details>
202+
132203
配置说明:
133204
- oneapi_type: OneAPI的类型,包括oneapi、newapi、onehub(保留字段,暂时无影响)
134205
- exclude_channel: 排除不予监控的渠道ID

README.md

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,24 @@ Channel Monitor is a tool designed for monitoring OneAPI/NewAPI channels. It dir
1919
- [x] Request rate limiting at the second level
2020
- [x] Support Uptime Kuma, push URL during testing to visualize model availability
2121
- [x] Support update notifications via SMTP email and Telegram Bot
22+
- [x] Support both JSON and YAML configuration formats
2223

2324
## Installation
2425

2526
### Binary
2627

27-
Download the latest version of the binary file from the [Releases](https://github.com/DullJZ/ChannelMonitor/releases) page. After configuring `config.json` in the same directory, you can run it. It is recommended to use tools like `screen` or `nohup` to run it in the background.
28+
Download the latest version of the binary file from the [Releases](https://github.com/DullJZ/ChannelMonitor/releases) page. After configuring `config.json` or `config.yaml` in the same directory, you can run it. It is recommended to use tools like `screen` or `nohup` to run it in the background.
2829
Note ⚠️: If you need to use an SQLite database, please use the Docker solution or compile yourself after enabling CGO.
2930

3031
```bash
3132
mkdir ChannelMonitor && cd ChannelMonitor
3233
wget https://github.com/DullJZ/ChannelMonitor/releases/download/v0.1.0/ChannelMonitor_linux_amd64
3334
chmod +x ChannelMonitor_linux_amd64
34-
# Download and modify the configuration file
35+
# Download and modify the configuration file (choose JSON or YAML format)
3536
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
36-
nano config.json
37+
# or use YAML format
38+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
39+
nano config.json # or nano config.yaml
3740
screen -S ChannelMonitor
3841
./ChannelMonitor_linux_amd64
3942
```
@@ -42,12 +45,16 @@ screen -S ChannelMonitor
4245

4346
```bash
4447
docker pull dulljz/channel-monitor
45-
# Download and modify the configuration file
48+
# Download and modify the configuration file (choose JSON or YAML format)
4649
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
47-
nano config.json
50+
# or use YAML format
51+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
52+
nano config.json # or nano config.yaml
4853
# If using the host's database, you can simply use the host mode,
4954
# and use localhost:3306 as the database address
5055
docker run -d --name ChannelMonitor -v ./config.json:/app/config.json --net host dulljz/channel-monitor
56+
# If using YAML format
57+
# docker run -d --name ChannelMonitor -v ./config.yaml:/app/config.yaml --net host dulljz/channel-monitor
5158
# If using an SQLite database, mount the database file
5259
# docker run -d --name ChannelMonitor -v ./config.json:/app/config.json -v /path/to/database.db:/app/database.db dulljz/channel-monitor
5360
```
@@ -61,6 +68,8 @@ services:
6168
image: dulljz/channel-monitor
6269
volumes:
6370
- ./config.json:/app/config.json
71+
# or use YAML format
72+
# - ./config.yaml:/app/config.yaml
6473
# If using an SQLite database, mount the database file
6574
# - /path/to/database.db:/app/database.db
6675
# If using the host's database, you can simply use the host mode,
@@ -69,15 +78,22 @@ services:
6978
```
7079
7180
```bash
72-
# Download and modify the configuration file
81+
# Download and modify the configuration file (choose JSON or YAML format)
7382
wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.json -O config.json
74-
nano config.json
83+
# or use YAML format
84+
# wget https://raw.githubusercontent.com/DullJZ/ChannelMonitor/refs/heads/main/config_example.yaml -O config.yaml
85+
nano config.json # or nano config.yaml
7586
docker-compose up -d
7687
```
7788

7889
## Configuration
7990

80-
The configuration file is `config.json` located in the same directory, with the following format:
91+
The configuration file can be either `config.json`, `config.yaml`, or `config.yml` in the same directory. The program will automatically detect and use the available configuration file in the order of `config.yaml` -> `config.yml` -> `config.json`.
92+
93+
### JSON Format
94+
95+
<details>
96+
<summary>Click to expand/collapse JSON configuration example</summary>
8197

8298
```json
8399
{
@@ -128,6 +144,61 @@ The configuration file is `config.json` located in the same directory, with the
128144
}
129145
```
130146

147+
</details>
148+
149+
### YAML Format
150+
151+
<details>
152+
<summary>Click to expand/collapse YAML configuration example</summary>
153+
154+
```yaml
155+
oneapi_type: oneapi
156+
exclude_channel: [5]
157+
exclude_model:
158+
- advanced-voice
159+
- minimax_s2v-01
160+
- minimax_video-01
161+
- minimax_video-01-live2d
162+
models:
163+
- gpt-3.5-turbo
164+
- gpt-4o
165+
force_models: false
166+
force_inside_models: false
167+
time_period: 1h
168+
max_concurrent: 5
169+
rps: 5
170+
db_type: YOUR_DB_TYPE
171+
db_dsn: YOUR_DB_DSN
172+
do_not_modify_db: false
173+
base_url: http://localhost:3000
174+
system_token: YOUR_SYSTEM_TOKEN
175+
uptime-kuma:
176+
status: disabled
177+
model_url:
178+
gpt-3.5-turbo: https://demo.kuma.pet/api/push/A12n43563?status=up&msg=OK&ping=
179+
gpt-4o: https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping=
180+
channel_url:
181+
"5": https://demo.kuma.pet/api/push/ArJd2BOUJN?status=up&msg=OK&ping=
182+
notification:
183+
smtp:
184+
enabled: false
185+
host: smtp.example.com
186+
port: 25
187+
188+
password: your-password
189+
190+
191+
webhook:
192+
enabled: false
193+
type: telegram
194+
telegram:
195+
chat_id: YOUR_CHAT_ID
196+
retry: 3
197+
secret: YOUR_WEBHOOK_SECRET
198+
```
199+
200+
</details>
201+
131202
Configuration explanation:
132203
- oneapi_type: Type of OneAPI, including oneapi, newapi, onehub (reserved field, currently has no effect)
133204
- exclude_channel: IDs of channels to exclude from monitoring

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.4.6
1+
v0.5.0

0 commit comments

Comments
 (0)