Skip to content

Commit 701d1b6

Browse files
Copilotikxin
andauthored
feat: 支持通过环境变量自定义监控频率 (#38)
* Initial plan * Add MONITOR_INTERVAL env variable for customizable monitoring frequency Co-authored-by: ikxin <54543761+ikxin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ikxin <54543761+ikxin@users.noreply.github.com>
1 parent c1622f9 commit 701d1b6

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
NUXT_PUBLIC_API_URL=https://kms.ikxin.com
22
NUXT_PUBLIC_I18N_BASE_URL=https://kms.ikxin.com
33
ENABLE_VLMCSD=false
4+
MONITOR_INTERVAL=10

README.en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ The static version uses https://kms.ikxin.com API by default. You can deploy you
7676
| --------------------- | --------------------------- | --------------------------------------------------- |
7777
| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | API URL for the static version |
7878
| `MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | Custom KMS server monitoring list, separated by `,` |
79+
| `MONITOR_INTERVAL` | `10` | Monitoring interval in seconds, default is 10 |
7980
| `ENABLE_VLMCSD` | `false` | Whether to enable the built-in VLMCSD service |
8081

8182
### Full-Stack Version

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ https://kms.ikxin.com
7676
| --------------------- | --------------------------- | ---------------------------------------- |
7777
| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | 静态版本 API 接口地址 |
7878
| `MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | 自定义监控 KMS 服务器列表,使用 `,` 分隔 |
79+
| `MONITOR_INTERVAL` | `10` | 监控频率,单位为秒,默认 10 秒 |
7980
| `ENABLE_VLMCSD` | `false` | 是否启用内置 VLMCSD 服务 |
8081

8182
### 全栈版本

nuxt.config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
3+
const getMonitorCron = () => {
4+
const raw = parseInt(process.env.MONITOR_INTERVAL || '10', 10)
5+
const seconds = isNaN(raw) || raw <= 0 ? 10 : raw
6+
if (seconds < 60) {
7+
return `*/${seconds} * * * * *`
8+
}
9+
const minutes = Math.floor(seconds / 60)
10+
return `0 */${minutes} * * * *`
11+
}
12+
213
export default defineNuxtConfig({
314
compatibilityDate: '2024-11-01',
415
devtools: { enabled: true },
@@ -10,7 +21,7 @@ export default defineNuxtConfig({
1021
tasks: true,
1122
},
1223
scheduledTasks: {
13-
'0/10 * * * * *': ['monitor'],
24+
[getMonitorCron()]: ['monitor'],
1425
},
1526
},
1627
app: {

0 commit comments

Comments
 (0)