MCPcopy
hub / github.com/dgraph-io/dgraph / ensureDgraphLinuxBinary

Function ensureDgraphLinuxBinary

t/t.go:204–226  ·  view source on GitHub ↗

ensureDgraphLinuxBinary checks if the dgraph binary exists under LINUX_GOBIN. If not found, it runs make install to build it.

()

Source from the content-addressed store, hash-verified

202// ensureDgraphLinuxBinary checks if the dgraph binary exists under LINUX_GOBIN.
203// If not found, it runs make install to build it.
204func 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
228func startCluster(composeFile, prefix string) error {
229 ensureGoPathLinuxBinEnvVarSet()

Callers 1

startClusterFunction · 0.85

Calls 5

commandFunction · 0.70
GetMethod · 0.65
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected