Skip to content

Services: Pass running services across watch iterations - #488

Merged
aomarks merged 8 commits into
servicefrom
service.10
Oct 28, 2022
Merged

Services: Pass running services across watch iterations#488
aomarks merged 8 commits into
servicefrom
service.10

Conversation

@aomarks

@aomarks aomarks commented Oct 28, 2022

Copy link
Copy Markdown
Member

Implements the basic logic for passing running services across watch mode iterations:

  1. The top-level execute method now returns a map of the services that are still running at the end of the execution.

  2. We pass that service map to the next iteration, and pass the previous version of each service into its new version.

  3. As soon as a service knows its fingerprint, we check if it matches the previous version's fingerprint. If it does match, we "adopt" it instead of starting a new process. If it does not match, we shut it down, and then continue as normal (effectively restarting it).

Still a few cases to handle here, which are in TODOs, but will do in followup PRs.

Part of #33

@aomarks
aomarks requested a review from justinfagnani October 28, 2022 17:56
@aomarks
aomarks force-pushed the service.10 branch 2 times, most recently from 7656e0f to bd81657 Compare October 28, 2022 18:06
Base automatically changed from service.9 to service October 28, 2022 20:30
@aomarks

aomarks commented Oct 28, 2022

Copy link
Copy Markdown
Member Author

Rebased (sorry if was already reviewing)

Comment thread src/execution/service.ts Outdated

/**
* Return the fingerprint of this service. If the fingerprint is not yet
* computed, or if the service is stopped/failed/detached, returns undefined.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why shouldn't it be an error to request a fingerprint before it's available?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, we probably should. Done.

Comment thread src/executor.ts
*/
async execute(): Promise<Result<void, Failure[]>> {
async execute(): Promise<Result<ServiceMap, Failure[]>> {
// TOOD(aomarks) If we have any running services from a previous watch

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do you plan on keeping services running across edits tot he wireit configs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, as long as the fingerprint stays the same for a service, we can keep it running. So if you change something that would require the service to restart, it will do so. Otherwise no need to restart it.

@aomarks
aomarks merged commit 55eccf3 into service Oct 28, 2022
@aomarks
aomarks deleted the service.10 branch October 28, 2022 23:00
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.

2 participants