main.go 758 Bytes
Newer Older
“李磊”'s avatar
“李磊” committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main

import (
	"time"

	"linkfog.com/pluginx/pluginmgr"
	"linkfog.com/public/lib/l"
)

func main() {
	pluginConfig := `{
		"testa": {
			"name": "testa",
			"path": "testdata/testa.sh",
			"enable": true,
			"mem": 419430400,
			"md5": "uninitialized"
		},
		"testb": {
			"name": "testb",
			"path": "testdata/testb.sh",
			"enable": true,
			"mem": 419430400,
			"md5": "uninitialized"
		}
	}`

	cfg, err := pluginmgr.LoadPluginConfigWithData([]byte(pluginConfig))
	if err != nil {
		l.Error("LoadPluginConfigWithData err:", err)
		return
	}
	for k, v := range cfg {
		l.Infof("plugin:%s, config:%v", k, v)
	}
	pluginmgr.EnableValidatePluginMD5 = false
	mgr := pluginmgr.NewProcessMgr(cfg)
	mgr.Start()
	time.Sleep(60 * time.Second)
	mgr.Stop()
}