Skip to content

Commit 676f37d

Browse files
author
root
committed
add feeds
1 parent 24f9036 commit 676f37d

57 files changed

Lines changed: 7245 additions & 284 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Note.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
## 资源
44

55
- 增加 strorage
6-
- 资源增加拷贝功能,即基于一个资源拷贝为新资源
76

87
### 服务器
98

109
- 服务器特殊环境配置:Docker 仓库地址、Docker 加速地址、代理地址
11-
- 环境预装机制:在线一键脚本或由 AppOS 推送到服务器后执行
1210

13-
## 隧道
14-
15-
- 隧道链接到服务器的 detail page
1611

1712
## Workflow
1813

@@ -146,16 +141,11 @@ Prerequisites
146141
ports tab 不稳定,经常打开显示 somethins wrong
147142

148143

149-
150144
addons 的 netdata restart 报错
151-
Server Terminal 退出连接后再重连,就会失败
152-
153-
crontab list 保存不住
154145

155146
去掉所有与 docker.sock 的强依赖与硬编码
156147

157-
平台metrics 的读取查询与对服务器 metrics 的查询,是不是后端代码应该分离
148+
rss 文章总数量,每个 source 文章上限问题,清理机制
158149

159-
所以 appos 容器內其實完全可以通過 uname -r、/proc/meminfo 等獲取宿主機的內核版本、內存大小、CPU 信息,不需要任何特殊權限。只有 OS 發行版(os-release)是個例外
160150

161151

backend/cmd/appos/bootstrap/cron.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/hibiken/asynq"
9+
"github.com/websoft9/appos/backend/domain/feeds"
910
"github.com/websoft9/appos/backend/domain/monitor"
1011
swcatalog "github.com/websoft9/appos/backend/domain/software/catalog"
1112
swinventory "github.com/websoft9/appos/backend/domain/software/inventory"
@@ -23,6 +24,7 @@ const monitorFactsPullCronJobID = "monitor_facts_pull"
2324
const monitorRuntimeSnapshotPullCronJobID = "monitor_runtime_snapshot_pull"
2425
const monitorCredentialCronJobID = "monitor_credential_checks"
2526
const monitorAppHealthCronJobID = "monitor_app_health_checks"
27+
const feedsPollCronJobID = "feeds_poll"
2628

2729
func registerCronHooks(app *pocketbase.PocketBase, asynqClient *asynq.Client) {
2830
app.Cron().MustAdd(
@@ -35,6 +37,16 @@ func registerCronHooks(app *pocketbase.PocketBase, asynqClient *asynq.Client) {
3537
}),
3638
)
3739

40+
app.Cron().MustAdd(
41+
feedsPollCronJobID,
42+
"*/5 * * * *",
43+
cronutil.Wrap(app, feedsPollCronJobID, func() {
44+
if _, err := feeds.PollDueSources(nil, app, nil, time.Now().UTC()); err != nil {
45+
panic(err)
46+
}
47+
}),
48+
)
49+
3850
if asynqClient == nil {
3951
return
4052
}

backend/cmd/appos/bootstrap/cron_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/pocketbase/pocketbase"
1011
swcatalog "github.com/websoft9/appos/backend/domain/software/catalog"
1112
)
1213

@@ -96,3 +97,16 @@ func TestShouldRunMonitorInterval(t *testing.T) {
9697
t.Fatal("expected 7-minute interval not to run at minute 15")
9798
}
9899
}
100+
101+
func TestRegisterCronHooksRegistersFeedsPollJob(t *testing.T) {
102+
app := pocketbase.New()
103+
registerCronHooks(app, nil)
104+
105+
for _, job := range app.Cron().Jobs() {
106+
if job.Id() == feedsPollCronJobID {
107+
return
108+
}
109+
}
110+
111+
t.Fatalf("expected cron job %q to be registered", feedsPollCronJobID)
112+
}

0 commit comments

Comments
 (0)