@procedures/server 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +15 -6
- package/dist/.tsbuildinfo +1 -1
- package/dist/host.d.ts +52 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +51 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts +11 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +53 -44
- package/dist/run.js.map +1 -1
- package/package.json +5 -4
- package/src/host.ts +76 -0
- package/src/index.ts +4 -2
- package/src/run.ts +70 -52
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @procedures/server
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9fccd90]
|
|
8
|
+
- Updated dependencies [b89e3fe]
|
|
9
|
+
- @procedures/peer@0.12.1
|
|
10
|
+
- @procedures/client@0.12.1
|
|
11
|
+
|
|
12
|
+
## 0.12.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 9ea2030: `runProcedureHost()` of `@procedures/server` is the one runner entry on `run()` of `@mark1russell7/service`, for `procedure-server`, `mark serve` and `mark --server` (server stack CLI-8, decisions D6, D7 and D17). This change is a break of the server stack, thus it is its own MINOR (decision D13).
|
|
17
|
+
|
|
18
|
+
- New `runProcedureHost({ name, host, mode, profile, lockfile, log, run })`. It declares the parts of `createProcedureHost()` in one service, and starts `run()`. It gives `{ host, service, life }` when the startup ends.
|
|
19
|
+
- The mode `foreground` has the profile `localDev`: a second Ctrl-C exits at once. The mode `background` has the profile `daemon`: a repeat signal has no effect. Each run declares `onRepeatSignal`. `HOST_PROFILES` gives the profiles as data.
|
|
20
|
+
- The caps of the stages sum to 10 s. They replace the hard-exit timer of 10 s of the entries.
|
|
21
|
+
- The lockfile is a dependency of the service: its connect writes it before the listeners start, and its close removes it after the listeners close. New `lockfileHandle(data)` of `@procedures/peer/lockfile`.
|
|
22
|
+
- `runServer()` (the bin `procedure-server` and `mark serve`) and `startServerMode()` (`mark --server`) install no signal handler and no hard-exit timer. Their promise ends with the lifecycle.
|
|
23
|
+
- `mark --server` is the background host (decision D17). `procedure-server` and `mark serve` run in the foreground.
|
|
24
|
+
- The entries map their transports to a host with `peerHostOptions()` of `@procedures/peer` (CLI-7).
|
|
25
|
+
- `ServerRunOptions.run` and the second argument of `startServerMode()` take the options of `run()`, for a test: a process port and a clock.
|
|
26
|
+
- A random token of `procedure-server` has 32 bytes, as the token of `mark --server`.
|
|
27
|
+
- The one-shot commands of `mark` keep their interrupt. CLI-26 moves them under `run()`.
|
|
28
|
+
|
|
29
|
+
The behavior that changes:
|
|
30
|
+
|
|
31
|
+
- A second Ctrl-C of `mark --server` has no effect: the host ends its drain, in 10 s at most. A second Ctrl-C of `procedure-server` and `mark serve` exits at once with the code 1, as before.
|
|
32
|
+
- The process exits with the code of the lifecycle: 0 after a clean shutdown, and 1 after an error or a startup that failed.
|
|
33
|
+
- A random token of `procedure-server` has 64 hexadecimal characters, not 48.
|
|
34
|
+
|
|
35
|
+
Migration steps:
|
|
36
|
+
|
|
37
|
+
- The site, MiniMongo, Graph and jarvis: no change is necessary. They do not start these entries.
|
|
38
|
+
- A script that starts `procedure-server` or `mark serve` and stops it with a signal: no change is necessary. Wait for the exit, in 10 s at most.
|
|
39
|
+
- A program that embeds the server outside a service: use `startServer()`, which starts it as a peer, and `peer.stop()`.
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [9ea2030]
|
|
44
|
+
- @procedures/peer@0.12.0
|
|
45
|
+
- @procedures/client@0.12.0
|
|
46
|
+
|
|
3
47
|
## 0.11.0
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -297,18 +297,27 @@ npx @mark1russell7/server-mongo
|
|
|
297
297
|
npx procedure-server --procedures @procedures/mongo/register
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
###
|
|
300
|
+
### The runner entry
|
|
301
301
|
|
|
302
|
-
The server CLI
|
|
302
|
+
The server CLI, `mark serve` and `mark --server` start through `runProcedureHost()` (CLI-8). It declares the parts of `createProcedureHost()` of `@procedures/peer` in one service of `@mark1russell7/service`, and starts `run()`.
|
|
303
303
|
|
|
304
304
|
```typescript
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
305
|
+
import { runProcedureHost } from "@procedures/server";
|
|
306
|
+
import { peerHostOptions } from "@procedures/peer";
|
|
307
|
+
|
|
308
|
+
const { host, life } = await runProcedureHost({
|
|
309
|
+
name: "procedure-server",
|
|
310
|
+
mode: "foreground",
|
|
311
|
+
host: peerHostOptions({ id, transports: [{ type: "http", port: 3000 }], registry, policy }),
|
|
309
312
|
});
|
|
313
|
+
await life.done; // the runner ends the process after the stop in stages
|
|
310
314
|
```
|
|
311
315
|
|
|
316
|
+
- **The signals.** The runner owns `SIGINT`, `SIGTERM` and `SIGQUIT`. The entry installs no signal handler and no hard-exit timer.
|
|
317
|
+
- **The profiles.** The mode `foreground` has the profile `localDev`: a second Ctrl-C exits at once. The mode `background` (`mark --server`) has the profile `daemon`: a repeat signal has no effect. The caps of the stages sum to 10 s.
|
|
318
|
+
- **The lockfile.** `lockfile` makes the lockfile a dependency of the service. The startup writes it before the listeners start, and the shutdown removes it after the listeners close.
|
|
319
|
+
- **Outside a service.** `startServer()` starts the same server as a peer, for a test or an app that has its own lifecycle.
|
|
320
|
+
|
|
312
321
|
### Package Hierarchy
|
|
313
322
|
|
|
314
323
|
```mermaid
|