ensureDgraphLinuxBinary checks if the dgraph binary exists under LINUX_GOBIN. If not found, it runs make install to build it.
()
| 202 | // ensureDgraphLinuxBinary checks if the dgraph binary exists under LINUX_GOBIN. |
| 203 | // If not found, it runs make install to build it. |
| 204 | func ensureDgraphLinuxBinary() error { |
| 205 | ensureGoPathLinuxBinEnvVarSet() |
| 206 | gopathLinuxBin := os.Getenv("LINUX_GOBIN") |
| 207 | dgraphBin := filepath.Join(gopathLinuxBin, buildvars.BinaryName.Get()) |
| 208 | |
| 209 | if _, err := os.Stat(dgraphBin); err == nil { |
| 210 | return nil // binary exists |
| 211 | } |
| 212 | |
| 213 | fmt.Printf("Dgraph binary not found at %s, building...\n", dgraphBin) |
| 214 | var cmd *exec.Cmd |
| 215 | if *race { |
| 216 | cmd = command("make", "BUILD_RACE=y", "install") |
| 217 | } else { |
| 218 | cmd = command("make", "install") |
| 219 | } |
| 220 | cmd.Dir = *baseDir |
| 221 | if err := cmd.Run(); err != nil { |
| 222 | return fmt.Errorf("failed to build dgraph binary: %w", err) |
| 223 | } |
| 224 | fmt.Printf("Dgraph binary built successfully at %s\n", dgraphBin) |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | func startCluster(composeFile, prefix string) error { |
| 229 | ensureGoPathLinuxBinEnvVarSet() |
no test coverage detected