Documentation ¶
Index ¶
- Variables
- func LoadPluginsByConfig(pl []api.PluginMeta) error
- func ParseCmdArgs()
- func ParsePluginConfig(basedir string, path string) error
- func UnloadPlugins() error
- type PluginDaemon
- func (pd *PluginDaemon) CreateCgroupHook(ctx context.Context, req *protos.CreateCgroupHookRequest) (*protos.CreateCgroupHookReply, error)
- func (pd *PluginDaemon) DestroyCgroupHook(ctx context.Context, req *protos.DestroyCgroupHookRequest) (*protos.DestroyCgroupHookReply, error)
- func (pd *PluginDaemon) EndHook(ctx context.Context, req *protos.EndHookRequest) (*protos.EndHookReply, error)
- func (pd *PluginDaemon) GracefulStop()
- func (pd *PluginDaemon) Launch(socket net.Listener) error
- func (pd *PluginDaemon) StartHook(ctx context.Context, req *protos.StartHookRequest) (*protos.StartHookReply, error)
- func (pd *PluginDaemon) Stop()
- type PluginLoaded
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FlagCraneConfig string FlagDebugLevel string )
View Source
var RootCmd = &cobra.Command{ Use: "cplugind", Short: "cplugind is a plugin daemon for CraneSched", Args: cobra.ExactArgs(0), Version: util.Version(), Run: func(cmd *cobra.Command, args []string) { util.DetectNetworkProxy() config := util.ParseConfig(FlagCraneConfig) if config == nil { log.Errorf("Failed to parse CraneSched config") os.Exit(util.ErrorCmdArg) } if err := ParsePluginConfig(config.CraneBaseDir, FlagCraneConfig); err != nil { log.Errorf("Failed to parse the plugin part in config: %v", err) os.Exit(util.ErrorCmdArg) } if !gPluginConfig.Enabled { log.Errorf("Plugind is disabled in config.") os.Exit(util.ErrorCmdArg) } if cmd.Flags().Changed("debug-level") { util.InitLogger(FlagDebugLevel) } else { util.InitLogger(gPluginConfig.LogLevel) } log.Info("Loading plugins...") if err := LoadPluginsByConfig(gPluginConfig.Plugins); err != nil { log.Errorf("Failed to load plugins: %v", err) os.Exit(util.ErrorCmdArg) } log.Info("Initializing plugins...") for _, p := range gPluginMap { if err := (*p).Load(p.Meta); err != nil { log.Errorf("Failed to init plugin: %v", err) os.Exit(util.ErrorGeneric) } } pd := NewPluginD(nil) unixSocket, err := util.GetUnixSocket(gPluginConfig.SockPath, 0600) if err != nil { log.Errorf("Failed to get UNIX socket: %v", err) os.Exit(util.ErrorGeneric) } log.Infof("gRPC server listening on %s.", gPluginConfig.SockPath) if err := pd.Launch(unixSocket); err != nil { log.Errorf("Failed to launch plugin daemon: %v", err) os.Exit(util.ErrorGeneric) } sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) sig := <-sigs switch sig { case syscall.SIGINT: log.Infof("Received SIGINT, exiting...") pd.GracefulStop() case syscall.SIGTERM: log.Infof("Received SIGTERM, exiting...") pd.Stop() } if err := UnloadPlugins(); err != nil { log.Errorf("Failed to unload plugins: %v", err) os.Exit(util.ErrorGeneric) } }, }
Functions ¶
func LoadPluginsByConfig ¶
func LoadPluginsByConfig(pl []api.PluginMeta) error
func ParseCmdArgs ¶
func ParseCmdArgs()
func ParsePluginConfig ¶
func UnloadPlugins ¶
func UnloadPlugins() error
Types ¶
type PluginDaemon ¶
type PluginDaemon struct { protos.UnimplementedCranePluginDServer Server *grpc.Server }
func NewPluginD ¶
func NewPluginD(opts []grpc.ServerOption) *PluginDaemon
func (*PluginDaemon) CreateCgroupHook ¶
func (pd *PluginDaemon) CreateCgroupHook(ctx context.Context, req *protos.CreateCgroupHookRequest) (*protos.CreateCgroupHookReply, error)
func (*PluginDaemon) DestroyCgroupHook ¶
func (pd *PluginDaemon) DestroyCgroupHook(ctx context.Context, req *protos.DestroyCgroupHookRequest) (*protos.DestroyCgroupHookReply, error)
func (*PluginDaemon) EndHook ¶
func (pd *PluginDaemon) EndHook(ctx context.Context, req *protos.EndHookRequest) (*protos.EndHookReply, error)
func (*PluginDaemon) GracefulStop ¶
func (pd *PluginDaemon) GracefulStop()
func (*PluginDaemon) StartHook ¶
func (pd *PluginDaemon) StartHook(ctx context.Context, req *protos.StartHookRequest) (*protos.StartHookReply, error)
func (*PluginDaemon) Stop ¶
func (pd *PluginDaemon) Stop()
type PluginLoaded ¶
type PluginLoaded struct { api.Plugin Meta api.PluginMeta }
Click to show internal directories.
Click to hide internal directories.