123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package cmd
- import (
- "context"
- "fmt"
- "kpt-pasture/dep"
- "gitee.com/xuyiping_admin/pkg/cmd"
- "gitee.com/xuyiping_admin/pkg/xerr"
- "github.com/spf13/cobra"
- )
- // CrontabCmd represents the crontab command
- var CrontabCmd = &cobra.Command{
- Use: "crontab",
- Short: "计划任务",
- Run: func(cmd *cobra.Command, args []string) {
- fmt.Println("crontab called")
- },
- }
- func init() {
- // 每日零点更新牛只日龄脚本
- cmd.Instant(JobCmd, "update:cowAge", UpdateCowDayAge, "更新牛只日龄")
- cmd.Instant(JobCmd, "gen:cowAge", GenerateWorkOrder, "创建每天的工单")
- }
- func UpdateCowDayAge(ctx context.Context, args []string) error {
- crontab := dep.DICrontabService()
- if err := crontab.UpdateCowInfo(); err != nil {
- xerr.ReportSentry(ctx, err)
- }
- return nil
- }
- func GenerateWorkOrder(ctx context.Context, args []string) error {
- crontab := dep.DICrontabService()
- if err := crontab.GenerateAsynqWorkOrder(); err != nil {
- xerr.ReportSentry(ctx, err)
- }
- return nil
- }
|