Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit 1 when process schema file fails and it's not cancelled. #2596

Merged
merged 4 commits into from
Sep 28, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 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 @@ -345,19 +347,19 @@ func run() {
if len(opt.schemaFile) > 0 {
if err := processSchemaFile(ctx, opt.schemaFile, dgraphClient); err != nil {
if err == context.Canceled {
log.Println("Interrupted while processing schema file")
} else {
log.Println(err)
log.Printf("Interrupted while processing schema file %q\n", opt.schemaFile)
return nil
}
return
log.Printf("Error while processing schema file %q: %s\n", opt.schemaFile, err)
return err
}
x.Printf("Processed schema file")
x.Printf("Processed schema file %q\n", opt.schemaFile)
}

filesList := fileList(opt.files)
totalFiles := len(filesList)
if totalFiles == 0 {
os.Exit(0)
return nil
}

// x.Check(dgraphClient.NewSyncMarks(filesList))
Expand All @@ -376,7 +378,8 @@ func run() {

for i := 0; i < totalFiles; i++ {
if err := <-errCh; err != nil {
log.Fatal("While processing file ", err)
log.Printf("Error while processing file %q: %s\n", err)
return err
}
}

Expand All @@ -396,10 +399,10 @@ func run() {
// Lets print an empty line, otherwise Interrupted or Number of Mutations overwrites the
// previous printed line.
fmt.Printf("%100s\r", "")

fmt.Printf("Number of TXs run : %d\n", c.TxnsDone)
fmt.Printf("Number of RDFs processed : %d\n", c.Rdfs)
fmt.Printf("Time spent : %v\n", c.Elapsed)

fmt.Printf("RDFs processed per second : %d\n", rate)

return nil
}