Skip to content

Commit

Permalink
update main so defer funcs are honored
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Oct 12, 2022
1 parent 878037b commit dffafa1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ignite/cmd/ignite/main.go
Expand Up @@ -12,22 +12,26 @@ import (
)

func main() {
os.Exit(run())
}

func run() int {
ctx := clictx.From(context.Background())

cmd := ignitecmd.New()

// Load plugins if any
if err := ignitecmd.LoadPlugins(ctx, cmd); err != nil {
fmt.Printf("Error while loading chain's plugins: %v\n", err)
os.Exit(1)
return 1
}
defer ignitecmd.UnloadPlugins()

err := cmd.ExecuteContext(ctx)

if ctx.Err() == context.Canceled || err == context.Canceled {
fmt.Println("aborted")
return
return 0
}

if err != nil {
Expand All @@ -38,7 +42,7 @@ func main() {
} else {
fmt.Println(err)
}

os.Exit(1)
return 1
}
return 0
}

0 comments on commit dffafa1

Please sign in to comment.