Skip to content

Add stopFirst option to stop services before running dependencies#1394

Open
RodrigoHamuy wants to merge 3 commits intogoogle:mainfrom
RodrigoHamuy:claude/cascade-cross-platform-issue-M1Vvi
Open

Add stopFirst option to stop services before running dependencies#1394
RodrigoHamuy wants to merge 3 commits intogoogle:mainfrom
RodrigoHamuy:claude/cascade-cross-platform-issue-M1Vvi

Conversation

@RodrigoHamuy
Copy link

@RodrigoHamuy RodrigoHamuy commented Mar 6, 2026

Summary

This PR adds a new stopFirst configuration option for script dependencies that allows stopping a running service before executing a dependency. This is useful when a dependency needs to write files that the service currently has open.

Key Changes

  • schema.json: Added stopFirst boolean property to dependency configuration with documentation explaining its purpose
  • src/config.ts: Added stopFirst: boolean field to the Dependency interface
  • src/analyzer.ts:
    • Added parsing logic to read the stopFirst property from configuration
    • Validates that stopFirst is a boolean value, reporting errors if invalid
    • Passes the stopFirst value to the dependency configuration
  • src/execution/service.ts:
    • Checks if any dependency has stopFirst: true before executing dependencies
    • If so, stops the adoptee (running service) before executing dependencies
    • Ensures the service is only stopped once and handles the case where the service is aborted while waiting for the adoptee to stop

Implementation Details

  • The stopFirst option defaults to false to maintain backward compatibility
  • When a dependency has stopFirst: true, the service is stopped before that dependency runs, allowing the dependency to freely write to files
  • The implementation properly handles async operations and state transitions during the stop/execute sequence

@google-cla
Copy link

google-cla bot commented Mar 6, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

WIP: adds early adoptee stop logic in _execute(); will be gated behind
a per-dependency flag (name TBD, e.g. preStop) before finalising.

https://claude.ai/code/session_01Be7upyt3ZRNdHuhyi1W7eF
Introduces a new per-dependency boolean option `stopFirst` (default: false).
When true on a dependency of a service, the running service (adoptee) is
stopped before that dependency executes. This allows dependencies to freely
write files the service may have open, avoiding file-lock and port conflicts
on both Unix and Windows.

Usage:
  "dependencies": [{"script": "build", "cascade": true, "stopFirst": true}]

https://claude.ai/code/session_01Be7upyt3ZRNdHuhyi1W7eF
@RodrigoHamuy RodrigoHamuy force-pushed the claude/cascade-cross-platform-issue-M1Vvi branch from e06169f to e658140 Compare March 6, 2026 10:49
@RodrigoHamuy RodrigoHamuy marked this pull request as ready for review March 6, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant