summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorMarkus Wolf <KnisterPeter@users.noreply.github.com>2022-05-24 16:52:25 +0200
committerGitHub <noreply@github.com>2022-05-24 16:52:25 +0200
commit4ef50eeae76f76af3ab0c8c7377c9388d28a0c38 (patch)
tree69935063e5eac429bbf641227865bd9ee4fdbeb6 /main.go
parentimplement pre and post steps (#1089) (diff)
downloadforgejo-act-4ef50eeae76f76af3ab0c8c7377c9388d28a0c38.tar.xz
forgejo-act-4ef50eeae76f76af3ab0c8c7377c9388d28a0c38.zip
feat: handle context cancelation during docker exec (#1170)
* feat: handle context cancelation during docker exec To allow interrupting docker exec (which could be long running) we process the log output in a go routine and handle context cancelation as well as command result. In case of context cancelation a CTRL+C is written into the docker container. This should be enough to terminate the running command. To make sure we do not get stuck during cleanup, we do set the cleanup contexts with a timeout of 5 minutes Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se> Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se> * feat: handle SIGTERM signal and abort run * test: on context cancel, abort running command This test makes sure that whenever the act Context was canceled, the currently running docker exec is sent a 0x03 (ctrl+c). Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de> * test: make sure the exec funcction handles command exit code This test makes sure that the exec function does handle docker command error results Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se> Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se> Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Diffstat (limited to 'main.go')
-rw-r--r--main.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/main.go b/main.go
index 14ed63d..41cf7c4 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"context"
"os"
"os/signal"
+ "syscall"
"github.com/nektos/act/cmd"
)
@@ -16,7 +17,7 @@ func main() {
// trap Ctrl+C and call cancel on the context
c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(c)
cancel()