Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Main is the main function of the program. Main = gcmd.Command{ Name: "main", Usage: "main", Brief: "start crontab job", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { g.Log().Info(ctx, `cron job start`) go service.Short().Execute(ctx) go service.Short().ExecuteAudit(ctx) if _, err = gcron.AddSingleton(ctx, "*/10 * * * * *", func(ctx context.Context) { ctx = helper.Helper().SetLogger(context.Background(), consts.Logger) if err := service.Short().AssignTask(ctx); err != nil { g.Log(consts.Logger).Info(ctx, "assign task error", err) } g.Log(consts.Logger).Info(ctx, "assign task success") }); err != nil { g.Log(consts.Logger).Error(ctx, "assign task add cron job error", err) return err } if _, err = gcron.AddSingleton(ctx, "0 */5 * * * *", func(ctx context.Context) { ctx = helper.Helper().SetLogger(context.Background(), consts.Logger) if err := service.Short().AuditAssignTask(ctx); err != nil { g.Log(consts.Logger).Info(ctx, "Audit assign task error", err) } g.Log(consts.Logger).Info(ctx, "Audit assign task success") }); err != nil { g.Log(consts.Logger).Error(ctx, "Audit assign task add cron job error", err) return err } if _, err = gcron.AddSingleton(ctx, "*/30 * * * * *", func(ctx context.Context) { ctx = helper.Helper().SetLogger(context.Background(), consts.Logger) if err := service.Short().ShortAccessLogSummary(ctx); err != nil { g.Log(consts.Logger).Info(ctx, "Short Access Log Summary task error", err) } g.Log(consts.Logger).Info(ctx, "Short Access Log Summary task success") }); err != nil { g.Log(consts.Logger).Error(ctx, "Short Access Log Summary task add cron job error", err) return err } if _, err = gcron.AddSingleton(ctx, "*/15 * * * * *", func(ctx context.Context) { ctx = helper.Helper().SetLogger(context.Background(), consts.Logger) if err := service.Short().AccessLog(ctx); err != nil { g.Log(consts.Logger).Info(ctx, "AccessLog task error", err) } g.Log(consts.Logger).Info(ctx, "AccessLog task success") }); err != nil { g.Log(consts.Logger).Error(ctx, "AccessLog task add cron job error", err) return err } gproc.AddSigHandlerShutdown(func(sig os.Signal) { g.Log().Info(ctx, `cron job shutdown`) }) g.Listen() return }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.