Skip to content

Services: Track when services are not needed - #473

Merged
aomarks merged 5 commits into
servicefrom
service.5
Oct 21, 2022
Merged

Services: Track when services are not needed#473
aomarks merged 5 commits into
servicefrom
service.5

Conversation

@aomarks

@aomarks aomarks commented Oct 21, 2022

Copy link
Copy Markdown
Member

Adds a servicesNotNeeded promise, which gets resolved when a script either knows it will never run, or when it has finished running, and hence no longer needs the services it depends on to be running. This is how services will keep track of how many dependents still need them to be running -- once there are none left, they can shut down (unless they are directly invoked).

This is done via a new BaseExecutionWithCommand base class, which is only relevant to scripts with commands (because no-command scripts don't directly consume services).

Also:

  • Pass abort promise down to services. Directly-invoked services will need this to know when to shut down on SIGINT.

  • Removed a redundant throw I noticed.

Part of #33

@aomarks
aomarks requested a review from justinfagnani October 21, 2022 17:25
Comment thread src/execution/standard.ts
if (this._shouldNotStart) {
return {ok: false, error: [this._startCancelledEvent]};
}
try {

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.

Note this is not a very well formatted diff. It's all indentation inside the try.

Comment thread src/executor.ts
config,
this,
this._logger,
this._abort.promise

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 aren't you using an AbortSignal?

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.

Because it's only supported in Node 15+, and we still support Node 14 until it goes out of LTS next year. Simpler than having a polyfill since it's so trivial anyway.

@aomarks
aomarks merged commit d8e3e76 into service Oct 21, 2022
@aomarks
aomarks deleted the service.5 branch October 21, 2022 17:46
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