From 83584a7e91fc9a9abbb2939688b801eba03137d2 Mon Sep 17 00:00:00 2001 From: srfrog Date: Fri, 14 Sep 2018 14:49:29 -0700 Subject: [PATCH] exit 1 when process schema file fails and it's not cancelled. Closes #2465 --- dgraph/cmd/live/run.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dgraph/cmd/live/run.go b/dgraph/cmd/live/run.go index ee1795fd559..9425e6477b2 100644 --- a/dgraph/cmd/live/run.go +++ b/dgraph/cmd/live/run.go @@ -61,7 +61,9 @@ func init() { Short: "Run Dgraph live loader", Run: func(cmd *cobra.Command, args []string) { defer x.StartProfile(Live.Conf).Stop() - run() + if err := run(); err != nil { + os.Exit(1) + } }, } Live.EnvPrefix = "DGRAPH_LIVE" @@ -292,7 +294,7 @@ func setup(opts batchMutationOptions, dc *dgo.Dgraph) *loader { return l } -func run() { +func run() error { opt = options{ files: Live.Conf.GetString("rdfs"), schemaFile: Live.Conf.GetString("schema"), @@ -346,10 +348,10 @@ func run() { if err := processSchemaFile(ctx, opt.schemaFile, dgraphClient); err != nil { if err == context.Canceled { log.Println("Interrupted while processing schema file") - } else { - log.Println(err) + return nil } - return + log.Printf("Error while processing schema file %q: %s\n", opt.schemaFile, err) + return err } x.Printf("Processed schema file") } @@ -402,4 +404,6 @@ func run() { fmt.Printf("Time spent : %v\n", c.Elapsed) fmt.Printf("RDFs processed per second : %d\n", rate) + + return nil }