Skip to content

Commit

Permalink
disconnect on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 7, 2023
1 parent e46a5af commit 5b38ecc
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (m *Migration) RunAndExit() {
}

m.CLI().Action = func(ctx *cli.Context) error {
log.Println("prepare")
log.Println("running")
var err error
m.client, err = mongo.Connect(m.ctx, options.Client().ApplyURI(m.config.uri))
if err != nil {
Expand All @@ -95,6 +95,10 @@ func (m *Migration) RunAndExit() {
}

if err := m.CLI().Run(os.Args); err != nil {
if m.client != nil {
m.client.Disconnect(m.ctx)
}

os.Exit(1)
}
}
Expand Down

0 comments on commit 5b38ecc

Please sign in to comment.