PluginExecute() executes the plugin control script to start the plugin process
(plugin string)
| 253 | |
| 254 | // PluginExecute() executes the plugin control script to start the plugin process |
| 255 | func (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 |
| 276 | func (c *Controller) PluginConnectSync() { |