You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ _Wireit upgrades your npm scripts to make them smarter and more efficient._
42
42
-[Cleaning output](#cleaning-output)
43
43
-[Watch mode](#watch-mode)
44
44
-[Services](#services)
45
+
-[Stop service before dependency](#stop-service-before-dependency)
45
46
-[Execution cascade](#execution-cascade)
46
47
-[Environment variables](#environment-variables)
47
48
-[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
585
586
dependencies change, except for dependencies with
586
587
[`cascade`](#execution-cascade) set to `false`.
587
588
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
+
588
619
### Service output
589
620
590
621
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
855
886
| `dependencies` | `string[] \| object[]` | `[]` | [Scripts that must run before this one](#dependencies). |
856
887
| `dependencies[i].script` | `string` | `undefined` | [The name of the script, when the dependency is an object.](#dependencies). |
857
888
| `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). |
858
890
| `files` | `string[]` | `undefined` | Input file [glob patterns](#glob-patterns), used to determine the [fingerprint](#fingerprint). |
859
891
| `output` | `string[]` | `undefined` | Output file [glob patterns](#glob-patterns), used for [caching](#caching) and [cleaning](#cleaning-output). |
0 commit comments