Skip to content

Commit

Permalink
exit 1 when process schema file fails and it's not cancelled.
Browse files Browse the repository at this point in the history
Closes #2465
  • Loading branch information
srfrog committed Sep 14, 2018
1 parent 66d9f94 commit 83584a7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions dgraph/cmd/live/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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
}

0 comments on commit 83584a7

Please sign in to comment.