fix: 修复定时健康检查两个bug
1. startupRun配置现在会在启动时立即运行健康检查 2. 修复快捷按钮重复绑定事件监听器的问题 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
129b4f688f
commit
21c92ff214
2 changed files with 15 additions and 1 deletions
|
|
@ -366,6 +366,18 @@ async function startServer() {
|
||||||
if (scheduledConfig?.enabled) {
|
if (scheduledConfig?.enabled) {
|
||||||
const interval = scheduledConfig.interval || CONFIG.CRON_NEAR_MINUTES * 60 * 1000;
|
const interval = scheduledConfig.interval || CONFIG.CRON_NEAR_MINUTES * 60 * 1000;
|
||||||
|
|
||||||
|
// 启动时运行健康检查
|
||||||
|
if (scheduledConfig.startupRun !== false) {
|
||||||
|
logger.info('[ScheduledHealthCheck] Running scheduled health check on startup...');
|
||||||
|
setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
await poolManager.performScheduledHealthChecks();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[ScheduledHealthCheck] Startup run error:', error);
|
||||||
|
}
|
||||||
|
}, 100); // 延迟100ms确保服务已完全就绪
|
||||||
|
}
|
||||||
|
|
||||||
// 设置定时任务
|
// 设置定时任务
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -251,9 +251,11 @@ async function loadConfiguration() {
|
||||||
if (scheduledHealthCheckIntervalEl) scheduledHealthCheckIntervalEl.value = 600000;
|
if (scheduledHealthCheckIntervalEl) scheduledHealthCheckIntervalEl.value = 600000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定时健康检查间隔快捷按钮
|
// 定时健康检查间隔快捷按钮(防止重复绑定)
|
||||||
const intervalQuickBtns = document.querySelectorAll('#scheduledHealthCheckInterval + .quick-select-btns button');
|
const intervalQuickBtns = document.querySelectorAll('#scheduledHealthCheckInterval + .quick-select-btns button');
|
||||||
intervalQuickBtns.forEach(btn => {
|
intervalQuickBtns.forEach(btn => {
|
||||||
|
if (btn.dataset.listenerAttached) return; // 防止重复绑定
|
||||||
|
btn.dataset.listenerAttached = 'true';
|
||||||
btn.addEventListener('click', (e) => {
|
btn.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const value = parseInt(btn.getAttribute('data-value'));
|
const value = parseInt(btn.getAttribute('data-value'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue