main.go 653 Bytes
Newer Older
Lei Li's avatar
Lei Li 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
package main

import (
	"basic-plugin/config"
	"os"
	"path/filepath"

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

func main() {
	pluginFuncs := map[string]PluginFunc{
		"start": nil,
		"stop":  nil,
	}
	pluginServer := newServer(config.ServicePluginName, pluginFuncs)

	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
	if err != nil {
		l.Errorf(err)
		os.Exit(1)
	}
	config.WorkDir = dir
	grpcServer, err := pluginrpc.NewPluginGrpcServer(filepath.Join(config.WorkDir, config.SockFile), pluginServer)
	if err != nil {
		l.Errorf("error creating plugin grpc server: %v", err)
		os.Exit(1)
	}
	defer grpcServer.Close()
	select {}
}