MCPcopy
hub / github.com/canopy-network/canopy / PluginExecute

Method PluginExecute

controller/controller.go:255–273  ·  view source on GitHub ↗

PluginExecute() executes the plugin control script to start the plugin process

(plugin string)

Source from the content-addressed store, hash-verified

253
254// PluginExecute() executes the plugin control script to start the plugin process
255func (c *Controller) PluginExecute(plugin string) {
256 if plugin == "" || strings.Contains(plugin, "..") || strings.ContainsRune(plugin, os.PathSeparator) {
257 c.log.Errorf("Invalid plugin name %q", plugin)
258 return
259 }
260 // construct the shell command path: plugin/<plugin>/pluginctl.sh start
261 cmdPath := filepath.Join("plugin", plugin, "pluginctl.sh")
262 // create the command to execute the plugin control script with 'start' argument
263 cmd := exec.Command(cmdPath, "start")
264 // execute the command and capture output
265 output, err := cmd.CombinedOutput()
266 // if an error occurred during execution
267 if err != nil {
268 // log the error and exit
269 c.log.Errorf("Failed to execute plugin %s: %v, output: %s", plugin, err, string(output))
270 }
271 // log successful plugin execution
272 c.log.Infof("Plugin %s started: %s", plugin, string(output))
273}
274
275// PluginConnectSync() blocking: enables a unix socket file where plugins can interact with the Canopy FSM
276func (c *Controller) PluginConnectSync() {

Callers 1

NewFunction · 0.80

Calls 3

ContainsMethod · 0.65
ErrorfMethod · 0.65
InfofMethod · 0.65

Tested by

no test coverage detected