recommender/cmd/schedule.go
2024-11-10 03:49:53 +08:00

49 lines
663 B
Go

package cmd
import (
"context"
"leafdev.top/Ecosystem/recommender/internal/base"
"sync"
"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) {
var wg sync.WaitGroup
var ctx = context.Background()
wg.Add(1)
// 启动一个定时器
go func() {
// defer cancel()
// run embedding
ctx.Done()
defer wg.Done()
}()
wg.Wait()
}