recommender/cmd/schedule.go

49 lines
663 B
Go
Raw Normal View History

2024-11-06 10:47:56 +00:00
package cmd
import (
2024-11-09 19:49:53 +00:00
"context"
2024-11-06 12:35:16 +00:00
"leafdev.top/Ecosystem/recommender/internal/base"
2024-11-09 19:49:53 +00:00
"sync"
2024-11-06 10:47:56 +00:00
"github.com/spf13/cobra"
)
func init() {
RootCmd.AddCommand(scheduleCmd)
}
var scheduleCmd = &cobra.Command{
Use: "schedule",
Short: "Schedule commands",
Long: `Schedule commands`,
Run: func(cmd *cobra.Command, args []string) {
app, err := CreateApp()
if err != nil {
panic(err)
}
runSchedule(app)
},
}
func runSchedule(app *base.Application) {
2024-11-09 19:49:53 +00:00
var wg sync.WaitGroup
2024-11-06 10:47:56 +00:00
2024-11-09 19:49:53 +00:00
var ctx = context.Background()
2024-11-06 10:47:56 +00:00
2024-11-09 19:49:53 +00:00
wg.Add(1)
// 启动一个定时器
go func() {
2024-11-06 10:47:56 +00:00
2024-11-09 19:49:53 +00:00
// defer cancel()
// run embedding
ctx.Done()
defer wg.Done()
}()
wg.Wait()
2024-11-06 10:47:56 +00:00
}