app: defer system.I revert
Just returning an error after a successful call of commit will leave garbage behind with no way for the caller to clean them. This change ensures revert is always called after successful commit with at least per-process state enabled. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
8
main.go
8
main.go
@@ -334,7 +334,7 @@ func runApp(config *fst.Config) {
|
||||
fmsg.PrintBaseError(err, "cannot seal app:")
|
||||
internal.Exit(1)
|
||||
} else if err = a.Run(ctx, rs); err != nil {
|
||||
if !rs.Start {
|
||||
if rs.Time == nil {
|
||||
fmsg.PrintBaseError(err, "cannot start app:")
|
||||
} else {
|
||||
logWaitError(err)
|
||||
@@ -344,6 +344,12 @@ func runApp(config *fst.Config) {
|
||||
rs.ExitCode = 126
|
||||
}
|
||||
}
|
||||
if rs.RevertErr != nil {
|
||||
fmsg.PrintBaseError(rs.RevertErr, "generic error returned during cleanup:")
|
||||
if rs.ExitCode == 0 {
|
||||
rs.ExitCode = 128
|
||||
}
|
||||
}
|
||||
if rs.WaitErr != nil {
|
||||
log.Println("inner wait failed:", rs.WaitErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user