tobogganSe connecter

louise

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Runtime, std: OS signals, graceful shutdown, supervised main (issue #306, ADR 0060)

A program could not learn it was asked to stop: as PID 1 SIGTERM was
ignored (`podman stop` waited 10.3 s, then SIGKILL), and otherwise it
killed the program mid-request.

- Signals: the runtime installs handlers for SIGTERM, SIGINT and SIGHUP
  (so PID 1 gets them), blocks them in every runtime thread and takes
  them on a signal thread. `os.signals([Term])` delivers them as
  messages; unsubscribed, they end the program at once with 128 + the
  signal (143 for SIGTERM), as PID 1 too. A live subscriber keeps
  deadlock detection from firing.
- `process.stop(pid)` and `ExitReason.Shutdown`: a trapping actor is
  told and returns; any other stops. A root stopped this way exits 0.
- `http.serve_until(server, settings, handler, stop)`: on any message on
  `stop`, refuse new clients (`net.close_listener` wakes the parked
  accept), close idle connections, finish busy ones with `Connection:
  close`, and return; `Settings.drain_timeout` (10 s) bounds it.
- Supervisors: `supervisor.run(Spec(strategy, children, intensity,
  period_ms))` counts restarts in a window; `ChildWith` gives a child a
  kind (`Permanent`, `Transient`, `Temporary`) and a shutdown timeout;
  told to stop, a supervisor stops its children last-started first,
  killing those past their timeout. `supervise` and `Child` keep their
  meaning.
- `[application]` in `louise.toml`: `louise run` and `louise build` run
  `main` under `supervisor.application` (a generated `+application`
  module): restarted after a crash within the intensity, stopped with
  `Shutdown` on SIGTERM or SIGINT, killed after `shutdown_timeout_ms`.
  `louise check` validates it; `louise test` ignores it.

Breaking: `ExitReason` has a fourth constructor, `Settings` a ninth
field, `proc` a fifteenth operation.

Tested natively: signals.rs (messages, default exits, PID 1 through
`unshare`), http_drain.rs, application.rs (both back ends for
restarts), and tests/run/supervisor_shutdown.lse on 1, 4 and 22
threads without leaks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

olivier · il y a 1 mois · 7e8aae2e29b13b0f13066530283c78c66a3cd5fc

Parents 0e68f2c

36 fichiers modifiés, 2263 ajouts, 60 suppressions

Acrates/louise/tests/application.rs+196−0
Acrates/louise/tests/fixtures/application/louise.toml+10−0
Acrates/louise/tests/fixtures/application/src/main.lse+48−0
Acrates/louise/tests/fixtures/http/drain.lse+40−0
Acrates/louise/tests/fixtures/signals/signals.lse+36−0
Acrates/louise/tests/http_drain.rs+121−0
Mcrates/louise_core/src/externs.rs+2−0
Mcrates/louise_interp/src/externs.rs+3−0
Mcrates/louise_interp/src/sched.rs+26−1
Mcrates/louise_package/src/manifest.rs+185−0
Adocs/adr/0060-signals-and-applications.md+141−0
Mruntime/louise_rt/include/louise_rt.h+3−0
Mruntime/louise_rt/src/process.rs+29−1
Mruntime/louise_rt/src/sched/actor.rs+3−0
Mruntime/louise_rt/src/sched/reactor.rs+16−2
Aruntime/louise_rt/src/signals.rs+188−0
Mruntime/louise_rt_prims/src/lib.rs+2−1
Atests/run/supervisor_shutdown.lse+309−0