package container import ( "fmt" "os/exec" "path" crc "git.loafle.net/commons_go/rpc/client" crr "git.loafle.net/commons_go/rpc/registry" oocc "git.loafle.net/overflow/overflow_commons_go/config" ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe" oopcc "git.loafle.net/overflow/overflow_probe_container/client" "git.loafle.net/overflow/overflow_probes/config" ) func New(port int, rpcInvoker crr.RPCInvoker) crc.Client { addr := fmt.Sprintf("localhost:%d", port) c := oopcc.New(addr, rpcInvoker) return c } func GetContainerCommand(name string) (cmd *exec.Cmd, pidPath string) { pidPath = path.Join(config.Config.Paths["root"], ooccp.PathPID, name+".pid") switch name { case ooccp.ContainerGeneralName: logConfigPath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerGeneralLogConfigFileName) javaPath := path.Join(config.Config.Paths["root"], ooccp.PathJRE, "bin", "java") jarPath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerGeneralFileName) // arg := fmt.Sprintf("-jar %s %s", jarPath, pidPath) cmd = exec.Command(javaPath, "-jar", jarPath, pidPath, logConfigPath) case ooccp.ContainerNetworkName: logConfigPath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerNetworkLogConfigFileName) exePath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerNetworkFileName) arg1 := fmt.Sprintf("-%s=%s", oocc.FlagPidFilePathName, pidPath) arg2 := fmt.Sprintf("-%s=%s", oocc.FlagLogConfigFilePathName, logConfigPath) cmd = exec.Command(exePath, arg1, arg2) case ooccp.ContainerDiscoveryName: logConfigPath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerDiscoveryLogConfigFileName) exePath := path.Join(config.Config.Paths["root"], ooccp.PathBin, ooccp.ContainerDiscoveryFileName) arg1 := fmt.Sprintf("-%s=%s", oocc.FlagPidFilePathName, pidPath) arg2 := fmt.Sprintf("-%s=%s", oocc.FlagLogConfigFilePathName, logConfigPath) cmd = exec.Command(exePath, arg1, arg2) default: } return }