Skip to content

[Fixes #242] Allow starting one service at a time#249

Open
mrclay wants to merge 2 commits into
2.x-RCfrom
242-single-service-start
Open

[Fixes #242] Allow starting one service at a time#249
mrclay wants to merge 2 commits into
2.x-RCfrom
242-single-service-start

Conversation

@mrclay

@mrclay mrclay commented May 6, 2026

Copy link
Copy Markdown
Contributor

ddev start still works, but you can alternately use ddev up nextjs or ddev up storybook to start with a single service.

kmonahan and others added 2 commits April 27, 2026 08:25
`ddev start` still works, but you can alternately use `ddev up nextjs` or `ddev up storybook` to start with a single service.
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request adds startup automation and documentation improvements. A new Bash script at .ddev/commands/host/up provides selective PM2 service management for Next.js, Storybook, or both. The .ddev/config.hooks.yaml post-start hook was restructured to delegate startup to the host context using environment-driven conditional execution and non-fatal npm ci handling. Documentation in README.project.md was updated with explicit service-specific startup sections including their respective commands and URLs, replacing the previous combined startup instruction.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding the ability to start individual services selectively rather than both at once.
Description check ✅ Passed The description accurately explains the new functionality and confirms backward compatibility, directly relating to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.ddev/commands/host/up:
- Around line 6-8: The script currently invokes START_UP_SERVICE=${SERVICE} ddev
start before validating SERVICE, so passing an invalid argument (e.g., `ddev up
typo`) will boot the stack then fail; move or add validation of SERVICE (ensure
SERVICE is one of the allowed values or matches existing service names, and
treat empty/malformed values) before the START_UP_SERVICE=${SERVICE} ddev start
call, and if invalid print the usage/error and exit non-zero; update both the
main startup path and the alternate branch that covers lines 12-25 so validation
happens before any ddev start invocation (refer to the SERVICE variable,
START_UP_SERVICE assignment, and the invalid-argument branch to locate places to
change).

In @.ddev/config.hooks.yaml:
- Line 4: The post-start hook currently masks installation failures because the
exec entry with "[ ! -d node_modules ] && npm ci || true" always returns
success; remove the trailing "|| true" and change the hook so it runs npm ci
only when node_modules is missing but does not swallow errors (e.g. use a shell
conditional that runs npm ci when node_modules is absent and lets npm's non-zero
exit code propagate); update the exec entry (the post-start exec command string)
accordingly so failed installs surface instead of being ignored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57d36cd4-67fc-434c-8fa7-4792c5a666d0

📥 Commits

Reviewing files that changed from the base of the PR and between 384a381 and 8ad74c4.

📒 Files selected for processing (3)
  • .ddev/commands/host/up
  • .ddev/config.hooks.yaml
  • README.project.md

Comment thread .ddev/commands/host/up
Comment on lines +6 to +8
SERVICE=${1:-all}

START_UP_SERVICE=${SERVICE} ddev start

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Validate SERVICE before starting DDEV

Line 8 triggers ddev start before the invalid-argument branch at Lines 23-25. ddev up typo still boots the stack, then exits with usage. Fail fast before startup.

Suggested patch
 SERVICE=${1:-all}
 
-START_UP_SERVICE=${SERVICE} ddev start
+case "$SERVICE" in
+  nextjs|storybook|all) ;;
+  *)
+    echo "Usage: ddev up [nextjs|storybook|all]"
+    exit 1
+    ;;
+esac
+
+START_UP_SERVICE="$SERVICE" ddev start
 
 echo "--- Selective PM2 Startup: $SERVICE ---"
 
-case $SERVICE in
+case "$SERVICE" in
   nextjs)
     ddev exec pm2 start --name next node_modules/.bin/next -- dev --webpack
     ;;
@@
-  *)
-    echo "Usage: ddev up [nextjs|storybook|all]"
-    exit 1
-    ;;
 esac

Also applies to: 12-25

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.ddev/commands/host/up around lines 6 - 8, The script currently invokes
START_UP_SERVICE=${SERVICE} ddev start before validating SERVICE, so passing an
invalid argument (e.g., `ddev up typo`) will boot the stack then fail; move or
add validation of SERVICE (ensure SERVICE is one of the allowed values or
matches existing service names, and treat empty/malformed values) before the
START_UP_SERVICE=${SERVICE} ddev start call, and if invalid print the
usage/error and exit non-zero; update both the main startup path and the
alternate branch that covers lines 12-25 so validation happens before any ddev
start invocation (refer to the SERVICE variable, START_UP_SERVICE assignment,
and the invalid-argument branch to locate places to change).

Comment thread .ddev/config.hooks.yaml
service: web
# pm2 does not live in the node path, so have to call binary directly
- exec: pm2 start --name storybook node_modules/.bin/storybook -- dev --no-open -p 6006
- exec: 'sh -c "[ ! -d node_modules ] && npm ci || true"'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t mask dependency install failures in post-start

Line 4 always succeeds due to || true, even when npm ci fails with missing node_modules. That can cascade into opaque startup failures later in the same post-start flow.

Suggested patch
-    - exec: 'sh -c "[ ! -d node_modules ] && npm ci || true"'
+    - exec: |
+        sh -c '
+          if [ ! -d node_modules ]; then
+            npm ci || {
+              echo "npm ci failed in web service. Run `ddev frontend install` and retry."
+              exit 1
+            }
+          fi
+        '
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.ddev/config.hooks.yaml at line 4, The post-start hook currently masks
installation failures because the exec entry with "[ ! -d node_modules ] && npm
ci || true" always returns success; remove the trailing "|| true" and change the
hook so it runs npm ci only when node_modules is missing but does not swallow
errors (e.g. use a shell conditional that runs npm ci when node_modules is
absent and lets npm's non-zero exit code propagate); update the exec entry (the
post-start exec command string) accordingly so failed installs surface instead
of being ignored.

@kmonahan kmonahan changed the base branch from 2.x to 2.x-RC June 1, 2026 13:12
@kmonahan kmonahan requested a review from mdrayer June 1, 2026 13:12
@kmonahan

kmonahan commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@mdrayer I know you were encountering slowness with ddev for MySI. Can you test locally whether this approach addresses any of the issues you were seeing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants