func (p *pi) newClient() { // note if the client is still running we can't p.client.Close() without a data-race // TODO investigate if there is a better way to clean-up if p.useJSON { p.client, p.err = pie.StartProviderCodec( jsonrpc.NewClientCodec, os.Stderr, p.cmdPath, p.args...) } else { p.client, p.err = pie.StartProvider(os.Stderr, p.cmdPath, p.args...) } if p.err != nil { p.err = fmt.Errorf("plugin %#v failed, error %v", *p, p.err) } }
func NewMapnik() (*Mapnik, error) { path, err := exec.LookPath(mapnikPluginName) if err != nil { path = filepath.Join(filepath.Dir(os.Args[0]), mapnikPluginName) path, _ = filepath.Abs(path) if _, serr := os.Stat(path); serr != nil { return nil, err } } client, err := pie.StartProvider(os.Stderr, path) if err != nil { return nil, err } return &Mapnik{client: client}, nil }