Skip to content

Commit

Permalink
kill persistent processes
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed May 9, 2024
1 parent 3f75758 commit 20695c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,28 @@ jobs:
expected: failure
actual: ${{ steps.sad_path_timeout.outcome }}

- name: sad-path (timeout persistent)
id: sad_path_timeout_persistent
uses: ./
continue-on-error: true
with:
timeout_seconds: 15
max_attempts: 2
command: |
node -e "
process.on('SIGTERM', () => {});
setInterval(() => {}, 1000);
setTimeout(() => { process.exit(0); }, 60000);
"
- uses: nick-invision/assert-action@v1
with:
expected: 2
actual: ${{ steps.sad_path_timeout_persistent.outputs.total_attempts }}
- uses: nick-invision/assert-action@v1
with:
expected: failure
actual: ${{ steps.sad_path_timeout_persistent.outcome }}

ci_integration_timeout_retry_on_timeout:
name: Run Integration Timeout Tests (retry_on timeout)
runs-on: ubuntu-latest
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function runCmd(attempt: number, inputs: Inputs) {
debug(`Signal: ${signal}`);

// timeouts are killed manually
if (signal === 'SIGTERM') {
if (signal === 'SIGTERM' || signal === 'SIGKILL') {
return;
}

Expand All @@ -117,6 +117,13 @@ async function runCmd(attempt: number, inputs: Inputs) {
timeout = true;
kill(child.pid);
await retryWait(ms.seconds(inputs.retry_wait_seconds));

while (!done) {
debug(`Sending SIGKILL to process ${child.pid}`);
kill(child.pid, 'SIGKILL');
await wait(ms.seconds(3));
}

throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
} else if (exit > 0) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
Expand Down

0 comments on commit 20695c2

Please sign in to comment.