mirror of
https://github.com/usememos/memos.git
synced 2025-02-10 16:30:53 +01:00
chore: update memo payload runner schedule
This commit is contained in:
parent
41d9c9d76e
commit
3b0be442de
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/usememos/gomark/ast"
|
||||
@ -25,23 +24,7 @@ func NewRunner(store *store.Store) *Runner {
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule runner every 12 hours.
|
||||
const runnerInterval = time.Hour * 12
|
||||
|
||||
func (r *Runner) Run(ctx context.Context) {
|
||||
ticker := time.NewTicker(runnerInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
r.RunOnce(ctx)
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RunOnce rebuilds the payload of all memos.
|
||||
func (r *Runner) RunOnce(ctx context.Context) {
|
||||
memos, err := r.Store.ListMemos(ctx, &store.FindMemo{})
|
||||
if err != nil {
|
||||
|
@ -147,11 +147,11 @@ func (s *Server) StartBackgroundRunners(ctx context.Context) {
|
||||
versionRunner := version.NewRunner(s.Store, s.Profile)
|
||||
versionRunner.RunOnce(ctx)
|
||||
memopayloadRunner := memopayload.NewRunner(s.Store)
|
||||
// Rebuild all memos' payload after server starts.
|
||||
memopayloadRunner.RunOnce(ctx)
|
||||
|
||||
go s3presignRunner.Run(ctx)
|
||||
go versionRunner.Run(ctx)
|
||||
go memopayloadRunner.Run(ctx)
|
||||
}
|
||||
|
||||
func (s *Server) getOrUpsertWorkspaceBasicSetting(ctx context.Context) (*storepb.WorkspaceBasicSetting, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user