Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Added `"service": true` setting, which is well suited for long-running
processes like servers. A service is started either when it is invoked directly,
or when another script that depends on it is ready to run. A service is stopped
when all scripts that depend on it have finished, or when Wireit is exited.

### Fixed

- Fixed memory leak in watch mode.

## [0.7.2] - 2022-09-25

### Fixed
Expand Down
16 changes: 16 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ const run = async (): Promise<Result<void, Failure[]>> => {
if (!result.ok) {
return result;
}
const persistentServices = result.value;
if (persistentServices.size > 0) {
const failures: Failure[] = [];
for (const service of persistentServices.values()) {
const result = await service.terminated;
if (!result.ok) {
failures.push(result.error);
}
}
if (failures.length > 0) {
return {
ok: false,
error: failures,
};
}
}
}
return {ok: true, value: undefined};
};
Expand Down
9 changes: 9 additions & 0 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export type Failure =
| DependencyOnMissingScript
| DependencyInvalid
| ServiceExitedUnexpectedly
| DependencyServiceExitedUnexpectedly
| Aborted;

interface ErrorBase<T extends PackageReference = ScriptReference>
Expand Down Expand Up @@ -250,6 +251,14 @@ export interface ServiceExitedUnexpectedly extends ErrorBase {
reason: 'service-exited-unexpectedly';
}

/**
* A service that we depend on exited before it was supposed to, causing us to
* fail as well.
*/
export interface DependencyServiceExitedUnexpectedly extends ErrorBase {
reason: 'dependency-service-exited-unexpectedly';
}

/**
* A script was killed or is refusing to run because it was intentionally
* aborted. Usually due to an error occuring in another script somewhere.
Expand Down
2 changes: 1 addition & 1 deletion src/execution/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export abstract class BaseExecutionWithCommand<
const errors: Failure[] = [];
for (const result of results) {
if (!result.ok) {
errors.push(...result.error);
errors.push(result.error);
}
}
if (errors.length > 0) {
Expand Down
Loading