mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-20 11:56:47 +08:00
feat: Support graceful job step cancellation (#69)
* for gh-act-runner * act-cli support as well * respecting always() and cancelled() of steps * setup-job, bug report, gh cli and watch wait call is cancelled early
This commit is contained in:
24
main.go
24
main.go
@@ -1,36 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/actions-oss/act-cli/cmd"
|
||||
"github.com/actions-oss/act-cli/pkg/common"
|
||||
)
|
||||
|
||||
//go:embed VERSION
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
// trap Ctrl+C and call cancel on the context
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
defer func() {
|
||||
signal.Stop(c)
|
||||
cancel()
|
||||
}()
|
||||
go func() {
|
||||
select {
|
||||
case <-c:
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
ctx, cancel := common.CreateGracefulJobCancellationContext()
|
||||
defer cancel()
|
||||
|
||||
// run the command
|
||||
cmd.Execute(ctx, version)
|
||||
|
||||
Reference in New Issue
Block a user