diff --git a/entrypoint.sh b/entrypoint.sh index 08df936..8a84f56 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -51,7 +51,7 @@ printf "Executing GitHub Runner for $GITHUB_REPOSITORY\n" if [[ -n $ECS_TASK_MAX_DURATION_SECONDS ]]; then echo "This task will stop after ${ECS_TASK_MAX_DURATION_SECONDS} seconds" - . /home/github/killProcess.sh "run.sh" & + . /home/github/killProcess.sh "/actions-runner/run.sh" & fi -. /actions-runner/run.sh +bash /actions-runner/run.sh diff --git a/killProcess.sh b/killProcess.sh index 1a1075d..a9634b7 100644 --- a/killProcess.sh +++ b/killProcess.sh @@ -3,9 +3,15 @@ sleep $ECS_TASK_MAX_DURATION_SECONDS PROCESS_TO_FIND=$1 +PROCESS_TO_KILL=$(ps -eux | grep -v "grep" | grep "$PROCESS_TO_FIND" | tr -s ' ') PID_TO_KILL=$(ps -eux | grep -v "grep" | grep "$PROCESS_TO_FIND" | tr -s ' ' | cut -d ' ' -f 2) echo "Task timeout" >&2 echo "Stop process $PROCESS_TO_FIND with PID: $PID_TO_KILL" >&2 +echo "Process name: $PROCESS_TO_KILL" -kill -9 $PID +# Graceful stop +kill -s TERM $PID_TO_KILL +sleep 30 + +kill -9 $PID_TO_KILL