@procedures/server 0.11.0 → 0.12.0

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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # @procedures/server
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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).
8
+
9
+ - 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.
10
+ - 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.
11
+ - The caps of the stages sum to 10 s. They replace the hard-exit timer of 10 s of the entries.
12
+ - 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`.
13
+ - `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.
14
+ - `mark --server` is the background host (decision D17). `procedure-server` and `mark serve` run in the foreground.
15
+ - The entries map their transports to a host with `peerHostOptions()` of `@procedures/peer` (CLI-7).
16
+ - `ServerRunOptions.run` and the second argument of `startServerMode()` take the options of `run()`, for a test: a process port and a clock.
17
+ - A random token of `procedure-server` has 32 bytes, as the token of `mark --server`.
18
+ - The one-shot commands of `mark` keep their interrupt. CLI-26 moves them under `run()`.
19
+
20
+ The behavior that changes:
21
+
22
+ - 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.
23
+ - The process exits with the code of the lifecycle: 0 after a clean shutdown, and 1 after an error or a startup that failed.
24
+ - A random token of `procedure-server` has 64 hexadecimal characters, not 48.
25
+
26
+ Migration steps:
27
+
28
+ - The site, MiniMongo, Graph and jarvis: no change is necessary. They do not start these entries.
29
+ - 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.
30
+ - A program that embeds the server outside a service: use `startServer()`, which starts it as a peer, and `peer.stop()`.
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [9ea2030]
35
+ - @procedures/peer@0.12.0
36
+ - @procedures/client@0.12.0
37
+
3
38
  ## 0.11.0
4
39
 
5
40
  ### 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
- ### With client-server
300
+ ### The runner entry
301
301
 
302
- The server CLI uses `server.create` procedure internally:
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
- // What the CLI does internally:
306
- await client.exec(["server", "create"], {
307
- transports: [{ type: "http", port: 3000, cors: true }],
308
- autoRegister: true,
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