moved
getclient
This commit is contained in:
parent
3424503357
commit
a68e9d5531
|
@ -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())
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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 {
|
func ReadConfig(path string ) *config.Config {
|
||||||
|
|
||||||
bytes, err := ioutil.ReadFile(path)
|
bytes, err := ioutil.ReadFile(path)
|
||||||
|
|
|
@ -37,6 +37,9 @@ func RunContainer(container *string, cpm *map[string][]string) {
|
||||||
log.Println(*container + " run success port:" , currentPort , "pid:", cmd.Process.Pid )
|
log.Println(*container + " run success port:" , currentPort , "pid:", cmd.Process.Pid )
|
||||||
//write pid file container_pid_port
|
//write pid file container_pid_port
|
||||||
ioutil.WriteFile(PidFolder+*container+"_"+strconv.Itoa(cmd.Process.Pid)+ "_"+strconv.Itoa(currentPort), []byte(""), os.ModePerm)
|
ioutil.WriteFile(PidFolder+*container+"_"+strconv.Itoa(cmd.Process.Pid)+ "_"+strconv.Itoa(currentPort), []byte(""), os.ModePerm)
|
||||||
|
|
||||||
|
portMap[*container] = strconv.Itoa(currentPort)
|
||||||
|
|
||||||
currentPort++
|
currentPort++
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user