Skip to content

fix(ddev-webserver): ddev stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 - #8396

Merged
rfay merged 1 commit into
ddev:mainfrom
rfay:20260508_rfay_faster_poweroff
May 10, 2026
Merged

rfay merged 1 commit into
ddev:mainfrom
rfay:20260508_rfay_faster_poweroff

Conversation

@rfay

@rfay rfay commented May 8, 2026 •

Copy link
Copy Markdown
Member

The Issue

ddev stop always takes ~10 seconds. So ddev poweroff takes a long time

How This PR Solves The Issue

pre-start.sh runs as PID 1 in the web container. It sets a SIGTERM trap to kill -- -1 (kill all processes in the container), then blocks on cat < ${logpipe}.

The bug: bash does not process signal traps while a foreground command is running. With cat in the foreground, the SIGTERM trap never fires when Docker sends SIGTERM to PID 1. kill -- -1 never runs, supervisord is never told to stop, nobody closes the write end of the named pipe, cat never gets EOF — a complete deadlock. Docker waits the full 10-second default grace period and then sends SIGKILL.

Fix: background cat and use wait instead. wait is a bash builtin that does allow signal processing, so SIGTERM fires the trap immediately, kill -- -1 stops all container processes, and the container exits cleanly in under a second.

Confirmed: supervisorctl stop all inside the container stops all processes (nginx, php-fpm, cron, mailpit) near-instantly, so there was never a problem with the supervised processes themselves — only with the signal never reaching the trap.

Timing

With v1.25.2: 11.5s to ddev stop

rfay@rfay-mba-m4:~/workspace/d11$ DDEV=/opt/homebrew/bin/ddev
rfay@rfay-mba-m4:~/workspace/d11$ $DDEV --version
ddev version v1.25.2
rfay@rfay-mba-m4:~/workspace/d11$ $DDEV start
...
$ time $DDEV stop
 Container ddev-d11-db Removed
 Container ddev-d11-web Removed
 Network ddev-d11_default Removed
Project d11 has been stopped.

real	0m11.556s
user	0m0.444s
sys	0m0.805s

With this PR, 1.4s to ddev stop

rfay@rfay-mba-m4:~/workspace/ddev$ DDEV=/Users/rfay/workspace/ddev/.gotmp/bin/darwin_arm64/ddev
rfay@rfay-mba-m4:~/workspace/ddev$ $DDEV --version
ddev version v1.25.2-28-g261434cf8
rfay@rfay-mba-m4:~/workspace/ddev$ $DDEV start
...
rfay@rfay-mba-m4:~/workspace/ddev$ time $DDEV stop d11
 Container ddev-d11-db Removed
 Container ddev-d11-web Removed
 Network ddev-d11_default Removed
Project d11 has been stopped.

real	0m1.399s
user	0m0.443s
sys	0m0.326s

Manual Testing Instructions

  • ddev start a project
  • `time ddev stop — should complete in ~1.5s instead of ~11.5s
  • ddev start && time ddev stop — should be way faster
  • ddev logs and ddev logs -f should work the same

Automated Testing Overview

No changes

Release/Deployment Notes

  • Release notes can mention that ddev stop and ddev poweroff are much faster

…being handled

## The Issue

`ddev stop` always takes ~10 seconds because Docker sends SIGTERM to PID 1
(`pre-start.sh`) and the container never exits cleanly, forcing Docker to
wait the full default stop_grace_period before sending SIGKILL.

## How This PR Solves The Issue

Bash does not process signal traps while a foreground command is running.
`cat < ${logpipe}` was blocking in the foreground, so the SIGTERM trap
never fired, `kill -- -1` never ran, supervisord was never told to stop,
nobody closed the write end of the pipe, and `cat` never got EOF — a
deadlock lasting exactly 10 seconds every time.

Fix: background `cat` and use `wait` instead. `wait` is a bash builtin
that allows signal processing, so SIGTERM fires the trap immediately,
`kill -- -1` stops all container processes, and the container exits cleanly
in under a second.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@rfay
rfay requested a review from a team as a code owner May 8, 2026 18:51
@github-actions github-actions Bot added bugfix dependencies Pull requests that update a dependency file labels May 8, 2026
@rfay rfay changed the title fix: web container stop takes 10s due to bash deferring SIGTERM during foreground cat fix: web container stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

@rfay rfay changed the title fix: web container stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 fix(ddev-webserver): web container stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 May 8, 2026
@rfay rfay changed the title fix(ddev-webserver): web container stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 fix(ddev-webserver): ddev stop takes 10s due to bash deferring SIGTERM during foreground cat, fixes #8295 May 9, 2026

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, so many test wins!

Check Main PR Difference
Docs Quickstart test 56m 40m PR faster by 16m
All Project Types / test 130m 82m PR faster by 48m
Apache-FPM / test 110m 72m PR faster by 38m
Docker Rootless / test 122m 87m PR faster by 35m
Mutagen / test 124m 79m PR faster by 45m
Nginx-FPM / test 114m 75m PR faster by 39m
No Bind Mounts / test 115m 89m PR faster by 26m
Podman Rootless / testcmd 86m 73m PR faster by 13m
Podman Rootless / testpkg-1 52m 42m PR faster by 10m
Podman Rootless / testpkg-2 58m 48m PR faster by 10m
Race Detection / test 143m 109m PR faster by 34m
WSL2 (nat) 197m 176m PR faster by 21m
buildkite/ddev-macos-arm64-mutagen 102m 98m PR faster by 4m
buildkite/macos-colima-vz 109m 59m PR faster by 50m
buildkite/macos-lima 94m 64m PR faster by 30m
buildkite/macos-orbstack 93m 60m PR faster by 33m

The add-on tests will be faster too, since all of them run ddev restart.

@rpkoller

rpkoller commented May 9, 2026

Copy link
Copy Markdown
Collaborator

wow, the amount of minutes saved is massive!

@rfay

rfay commented May 10, 2026

Copy link
Copy Markdown
Member Author

Your improved UI made this possible @stasadev !

@rfay
rfay merged commit 3d29d0a into ddev:main May 10, 2026
54 of 55 checks passed
@rfay
rfay deleted the 20260508_rfay_faster_poweroff branch May 10, 2026 00:49
stasadev added a commit to ddev-test/ddev that referenced this pull request May 11, 2026
…e unused workflows [skip buildkite]

## The Issue

From ddev#8396 (review):

| Check | Main | PR | Difference |
|---|---|---|---|
| Podman Rootless / testcmd | 86m | 73m | PR faster by 13m |
| Podman Rootless / testpkg-1 | 52m | 42m | PR faster by 10m |
| Podman Rootless / testpkg-2 | 58m | 48m | PR faster by 10m |
| WSL2 (nat) | 197m | 176m | PR faster by 21m |

We don't need to split testpkg for Podman anymore, it can be done as one job.
WSL2 (nat) takes too much time, it's better to split it into testcmd/testpkg

## How This PR Solves The Issue

- Improves CI workflow structure for faster and more flexible test runs
- **Split testpkg/testcmd**: All podman and WSL2 workflows now run `testpkg` and `testcmd` as separate parallel jobs instead of a combined `test` target, reducing wall-clock time
- **Remove A-G/H-Z testpkg split**: Podman rootless/root workflows previously split testpkg into two regex-filtered halves; these are merged into a single `testpkg` job now that testpkg+testcmd run in parallel
- **WSL2 refactored**: `test-wsl2.yml` replaced with a reusable `test-wsl2-reusable.yml` plus separate `test-wsl2-nat.yml` and `test-wsl2-mirrored.yml` (mirrored not yet running, pending microsoft/WSL#11154)
- **Custom dispatch jobs**: All test workflows gain a `workflow_dispatch`-only custom job with `make_target` (choice), `testargs`, `gotest_short`, and `makeargs` inputs, allowing any test target to be run manually from the GitHub Actions UI without changing workflow files
- **Removed unused workflows**: `colima-tests.yml`, `test-podman-root.yml`, `test-podman-root-mutagen.yml` removed as they were not running
- **actions/checkout v5 → v6**: Bumped across all workflows

## Manual Testing Instructions

- Trigger any test workflow via `workflow_dispatch` and verify the custom job appears with dropdown options for `make_target`
- Verify PR/push triggers run the standard split jobs (not the custom job)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ddev poweroff takes longer than it should, seems to hang after each project is stopped

3 participants