getclient
This commit is contained in:
snoop 2017-04-14 17:23:32 +09:00
parent 3424503357
commit a68e9d5531
3 changed files with 14 additions and 12 deletions

View File

@ -1,10 +0,0 @@
package crawler_manager
import "google.golang.org/grpc"
type GRPCPool struct {
}
func (c *GRPCPool)GetClient(container string,port string) (*grpc.ClientConn, error) {
return grpc.Dial("localhost:50000", grpc.WithInsecure())
}

View File

@ -11,7 +11,7 @@ import (
"io/ioutil"
"google.golang.org/grpc"
)
const (
@ -26,7 +26,7 @@ const (
)
type crawler_manager struct {
type CrawlerManager struct {
}
@ -44,6 +44,15 @@ func init() {
}
func (c *CrawlerManager)GetClient(container string,port string) (*grpc.ClientConn, error) {
port = portMap[container]
return grpc.Dial("localhost:"+port, grpc.WithInsecure())
}
func ReadConfig(path string ) *config.Config {
bytes, err := ioutil.ReadFile(path)

View File

@ -37,6 +37,9 @@ func RunContainer(container *string, cpm *map[string][]string) {
log.Println(*container + " run success port:" , currentPort , "pid:", cmd.Process.Pid )
//write pid file container_pid_port
ioutil.WriteFile(PidFolder+*container+"_"+strconv.Itoa(cmd.Process.Pid)+ "_"+strconv.Itoa(currentPort), []byte(""), os.ModePerm)
portMap[*container] = strconv.Itoa(currentPort)
currentPort++
break;