[Chenyu Zhao]: add code comment
@@ -142,9 +142,11 @@ func (CbpfPluginFactory) CreatePlugin(pluginName string, pluginType string) (Plu
var pluginPid = make(map[string]int, 10)
func runSinglePlugin(e request.PluginInfo, timeout int, out *chan int, errch *chan error) {
+ // TODO
db := global.GVA_DB.Model(&ebpfplugins.EbpfPlugins{})
var plugin ebpfplugins.EbpfPlugins
db.Where("id = ?", e.PluginId).First(&plugin)
+
cmd := exec.Command("sudo", "python3", "-u", plugin.PluginPath)
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
@@ -154,6 +156,7 @@ func runSinglePlugin(e request.PluginInfo, timeout int, out *chan int, errch *ch
*errch <- err
}
defer stdout.Close()
+ // TODO: delete timeout
go func() {
scanner := bufio.NewScanner(stdout)
linechan := make(chan string, 1)
@@ -162,6 +165,7 @@ func runSinglePlugin(e request.PluginInfo, timeout int, out *chan int, errch *ch
linechan <- scanner.Text()
select {
case line := <-linechan:
+ // TODO: delete
fmt.Println(line)
*out <- 1
if len(*out) >= 1 {
@@ -200,6 +204,7 @@ func runSinglePlugin(e request.PluginInfo, timeout int, out *chan int, errch *ch
}
defer fmt.Printf("Process finished!")
}
+
func killProcess(path string) {
if err := syscall.Kill(-pluginPid[path], syscall.SIGKILL); err != nil {
return
