liuhaijun 3f5f28d785 add sheduling agent
Change-Id: I89f35fb3984044c57f10727432755012542f9fd8
2023-11-16 10:55:57 +00:00

33 lines
656 B
Go

package mrunners
import (
"context"
"git.inspur.com/sbg-jszt/cfn/cfn-schedule-agent/pkg/process-manager/munit"
)
func init() {
Register(munit.KindOnce, func(opts RunnerOptions) (runner Runner, err error) {
if err = opts.Unit.RequireCommand(); err != nil {
return
}
runner.Order = 20
runner.Action = &runnerOnce{RunnerOptions: opts}
return
})
}
type runnerOnce struct {
RunnerOptions
}
func (r *runnerOnce) Do(ctx context.Context) {
r.Print("controller started")
defer r.Print("controller exited")
if err := r.Exec.Execute(r.Unit.ExecuteOptions(r.Logger)); err != nil {
r.Error("failed executing: " + err.Error())
return
}
}