Skip to content

Commit e658140

Browse files
committed
Document stopFirst dependency option in README
https://claude.ai/code/session_01Be7upyt3ZRNdHuhyi1W7eF
1 parent 048b1e9 commit e658140

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ _Wireit upgrades your npm scripts to make them smarter and more efficient._
4242
- [Cleaning output](#cleaning-output)
4343
- [Watch mode](#watch-mode)
4444
- [Services](#services)
45+
- [Stop service before dependency](#stop-service-before-dependency)
4546
- [Execution cascade](#execution-cascade)
4647
- [Environment variables](#environment-variables)
4748
- [Failures and errors](#failures-and-errors)
@@ -585,6 +586,36 @@ In watch mode, a service will be restarted whenever one of its input files or
585586
dependencies change, except for dependencies with
586587
[`cascade`](#execution-cascade) set to `false`.
587588

589+
### Stop service before dependency
590+
591+
By default, when a service restarts in watch mode its previous instance keeps
592+
running while its dependencies execute, and is only stopped once the new
593+
fingerprint has been computed. This allows the service to keep serving requests
594+
for as long as possible.
595+
596+
However, if a dependency needs to write files that the service has open (e.g.
597+
recompiling output that the service reads from disk), the running service can
598+
interfere. Setting `stopFirst: true` on that dependency tells Wireit to stop
599+
the service _before_ the dependency runs:
600+
601+
```json
602+
{
603+
"command": "node my-server.js",
604+
"dependencies": [
605+
{
606+
"script": "build",
607+
"cascade": true,
608+
"stopFirst": true
609+
}
610+
]
611+
}
612+
```
613+
614+
> **Note**
615+
> When `stopFirst` is `true` the service is always stopped before the
616+
> dependency runs, even if the fingerprint ultimately does not change. Accept
617+
> the extra downtime in exchange for avoiding file-lock or port conflicts.
618+
588619
### Service output
589620

590621
Services cannot have `output` files, because there is no way for Wireit to know
@@ -855,6 +886,7 @@ The following properties can be set inside `wireit.<script>` objects in
855886
| `dependencies` | `string[] \| object[]` | `[]` | [Scripts that must run before this one](#dependencies). |
856887
| `dependencies[i].script` | `string` | `undefined` | [The name of the script, when the dependency is an object.](#dependencies). |
857888
| `dependencies[i].cascade` | `boolean` | `true` | [Whether this dependency always causes this script to re-execute](#execution-cascade). |
889+
| `dependencies[i].stopFirst` | `boolean` | `false` | [Whether a service dependent should be stopped before this dependency runs](#stop-service-before-dependency). |
858890
| `files` | `string[]` | `undefined` | Input file [glob patterns](#glob-patterns), used to determine the [fingerprint](#fingerprint). |
859891
| `output` | `string[]` | `undefined` | Output file [glob patterns](#glob-patterns), used for [caching](#caching) and [cleaning](#cleaning-output). |
860892
| `clean` | `boolean \| "if-file-deleted"` | `true` | [Delete output files before running](#cleaning-output). |

0 commit comments

Comments
 (0)