49 lines
663 B
Go
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()
|
|
}
|