更改存档异步等待

This commit is contained in:
2024-12-16 09:00:59 +08:00
parent c97825b54f
commit 8372b221ee

14
main.js
View File

@@ -76,9 +76,9 @@ export default function () {
}
}
setInterval(async () => {
// 定时执行任务,确保上一次执行完毕后才开始下一轮
async function startScheduledTask() {
while (true) {
try {
存档('每10分钟自动存档...')
await update('web_images', 'day_rank', Object.entries(Object.fromEntries(截图.浏览数.)))
@@ -87,10 +87,12 @@ export default function () {
} catch(err) {
console.error(err)
}
await new Promise(resolve => setTimeout(resolve, 10 * 1000))
}
}
}, 10000)
// 启动定时任务
startScheduledTask()
console.log(当前日期, '开始收集日志...')
const tail = new Tail('/opt/log/caddy/access.log')