diff --git a/README.md b/README.md index 9853856fb..3ec517feb 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ _Wireit upgrades your npm scripts to make them smarter and more efficient._ - [Cleaning output](#cleaning-output) - [Watch mode](#watch-mode) - [Services](#services) + - [Stop service before dependency](#stop-service-before-dependency) - [Execution cascade](#execution-cascade) - [Environment variables](#environment-variables) - [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 dependencies change, except for dependencies with [`cascade`](#execution-cascade) set to `false`. +### Stop service before dependency + +By default, when a service restarts in watch mode its previous instance keeps +running while its dependencies execute, and is only stopped once the new +fingerprint has been computed. This allows the service to keep serving requests +for as long as possible. + +However, if a dependency needs to write files that the service has open (e.g. +recompiling output that the service reads from disk), the running service can +interfere. Setting `stopFirst: true` on that dependency tells Wireit to stop +the service _before_ the dependency runs: + +```json +{ + "command": "node my-server.js", + "dependencies": [ + { + "script": "build", + "cascade": true, + "stopFirst": true + } + ] +} +``` + +> **Note** +> When `stopFirst` is `true` the service is always stopped before the +> dependency runs, even if the fingerprint ultimately does not change. Accept +> the extra downtime in exchange for avoiding file-lock or port conflicts. + ### Service output 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.