move plugin handling outside the sdk package

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-01-05 11:37:45 +01:00
parent 2912b2e92e
commit 7c68b03d07
37 changed files with 772 additions and 800 deletions

25
plugin/util.go Normal file
View File

@@ -0,0 +1,25 @@
package plugin
import (
"github.com/shirou/gopsutil/v3/process"
"github.com/drakkan/sftpgo/v2/logger"
)
func killProcess(processPath string) {
procs, err := process.Processes()
if err != nil {
return
}
for _, p := range procs {
cmdLine, err := p.Exe()
if err == nil {
if cmdLine == processPath {
err = p.Kill()
logger.Debug(logSender, "killed process %v, pid %v, err %v", cmdLine, p.Pid, err)
return
}
}
}
logger.Debug(logSender, "no match for plugin process %v", processPath)
}