1
1
mirror of https://github.com/nektos/act.git synced 2024-09-11 12:35:25 +03:00

fix: close

This commit is contained in:
Jason Song 2023-04-27 17:54:48 +08:00
parent ddf9d69f37
commit d53ea7568b
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5

View File

@ -607,7 +607,10 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
return err
}
var finallyFuncs []func()
cancel := artifacts.Serve(ctx, input.artifactServerPath, input.artifactServerAddr, input.artifactServerPort)
finallyFuncs = append(finallyFuncs, cancel)
if !input.noCacheServer {
cacheHandler, err := artifactcache.StartHandler(input.cacheServerPath, input.cacheServerAddr, input.cacheServerPort, common.Logger(ctx))
@ -615,6 +618,9 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
return err
}
envs["ACTIONS_CACHE_URL"] = cacheHandler.ExternalURL() + "/"
finallyFuncs = append(finallyFuncs, func() {
_ = cacheHandler.Close()
})
}
ctx = common.WithDryrun(ctx, input.dryrun)
@ -629,8 +635,9 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
}
executor := r.NewPlanExecutor(plan).Finally(func(ctx context.Context) error {
cancel()
_ = cacheHandler.Close()
for _, f := range finallyFuncs {
f()
}
return nil
})
err = executor(ctx)