Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
1eb9bca5
Commit
1eb9bca5
authored
Jul 03, 2025
by
Haohao Jiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: trigger processDetect if isMonday11AM OR should_run_tasks checked in redis
parent
af7cd467
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
index.ts
index.ts
+33
-1
No files found.
index.ts
View file @
1eb9bca5
import
{
spawn
}
from
"bun"
;
import
Redis
from
"ioredis"
;
// 任务执行入口,自动设置 SLACK_WEBHOOK 并依次运行 gsheet、gsheet:ai 和 notify-slack
async
function
main
()
{
async
function
processDetect
()
{
const
env
=
{
...
process
.
env
};
...
...
@@ -44,6 +45,37 @@ async function main() {
});
}
function
isMonday11AM
()
{
const
now
=
new
Date
();
return
now
.
getDay
()
===
1
&&
now
.
getHours
()
===
11
;
}
async
function
main
()
{
const
redis
=
new
Redis
(
Bun
.
env
.
REDIS_URL
);
const
shouldRun
=
await
redis
.
get
(
"falcon:should_run_tasks"
);
if
(
shouldRun
===
"true"
)
{
await
processDetect
();
await
redis
.
del
(
"falcon:should_run_tasks"
);
console
.
log
(
"should_run_tasks 执行完毕,已清理 redis key。"
);
}
else
if
(
isMonday11AM
())
{
const
mondayKey
=
"falcon:monday_11am_executed"
;
const
alreadyExecuted
=
await
redis
.
get
(
mondayKey
);
if
(
alreadyExecuted
)
{
console
.
log
(
"本周一11点任务已执行,跳过。"
);
}
else
{
await
processDetect
();
// 设置标记,24小时后自动过期
await
redis
.
set
(
mondayKey
,
"true"
,
"EX"
,
60
*
60
*
24
);
console
.
log
(
"定时任务触发,已执行 main 逻辑,并设置本周标记。"
);
}
}
else
{
console
.
log
(
"should_run_tasks 不是 'true',且不是定时任务,跳过。"
);
}
await
redis
.
quit
();
}
// 调用入口
main
().
catch
(
err
=>
{
console
.
error
(
err
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment