http server updates and docs
This commit is contained in:
@@ -71,7 +71,7 @@ Use **`execLine`** when you want users to type natural shell commands from your
|
||||
1. **Keep the loop async**—never block on synchronous host APIs that might hang the Pear app.
|
||||
2. **Catch errors** around `execLine` so a typo does not tear down the whole session unless you want that.
|
||||
3. **Do not assume `import`**—the kernel source is the same `AsyncFunction` model as `/bin` (Chapter 1).
|
||||
4. To add **startup services**, prefer hooks already wired in the booter (**`startBareInitd`**) or a small kernel that calls **`runBinCommand`** after banner—see [Chapter 7](07-apps-beyond-the-shell.md).
|
||||
4. To add **startup services**, prefer hooks already wired in the booter (**`startBareInitd`**)—stock units include **`bare-os-www`** (loopback HTTP for **`~/.www`**, see [Handbook ch.4](../handbook/04-the-booter-runtime.md#bare-os-www-static-http-for-www))—or a small kernel that calls **`runBinCommand`** after banner; see [Chapter 7](07-apps-beyond-the-shell.md).
|
||||
5. To run code when the session ends, use **`ctx.registerKernelShutdownHook(fn)`** (runs before initd disposers); see [Chapter 2 — `ctx`](02-the-context-object.md).
|
||||
6. After **`login`**, **`~/.barerc`** is reloaded automatically via **`applyUnlockedEnv`**—see [Handbook — Identity](../handbook/05-identity-vault-and-hdms.md). The stock **`init.js`** does not re-print the boot banner; use **`onIdentityUnlocked`** or a custom kernel loop if you want that.
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ This chapter ties the Hyperdrive-resident kernel ([`kernel/init.js`](../kernel/i
|
||||
## Init, timers, and sockets
|
||||
|
||||
- **bare-initd** — User drop-ins under `~/.config/bare-os/units/<name>.unit` support `SocketActivationIpc=<fifo>`; the unit’s `start` runs after the first byte is read on that logical FIFO under `/run/bare-os/ipc/…`. Optional `IdleSec=N` (with `stop`) stops the unit after N seconds without further IPC traffic; optional fragments `~/.config/bare-os/units.d/<name>/*.conf` merge before `~/.config/bare-init/units/` overrides. `ReadinessPath=` may be `exec:<execLine>` for a bounded readiness gate. **`ConditionPathExists=`** skips start when a VFS path is missing; **`AssertPathExists=`** fails the unit when missing (systemd-like, bounded absolute paths). **`ConditionPathIsDirectory=`** / **`AssertPathIsDirectory=`** do the same for directories (via **`vfs.lstat`**). Inspect the live DAG at **`/proc/bare_os/initd_graph.json`** (same payload as **`initd_dag.json`**, optional **`dot`** field).
|
||||
- **bare-os-www** — Stock initd serves **`GET`/`HEAD`** from **`~/.www`** on **`127.0.0.1:8088`** by default; **`bare-holesail`** starts after it so managed **`bare-www-<port>`** rows reach the listener. Handbook [ch.4 § bare-os-www](../handbook/04-the-booter-runtime.md#bare-os-www-static-http-for-www).
|
||||
- **Timers** — Files in `~/.config/bare-os/timers/*.timer` (max **8**) with a `[Timer]` section: either `OnCalendar=` (five cron fields) + `ExecLine=` on the same minute tick as `~/.crontab`, or `EveryMs=` (**1000**–**86400000**) + `ExecLine=` on a fixed `setInterval`, or **`OnInactiveSec=`** to run after the last timer-triggered finish plus an idle gap (one-shot or repeating; **`Persistent=`** keeps state across sessions where implemented). Optional `JitterSec=` spreads the first (or periodic) `execLine` within **0…N** seconds. Copy from `/etc/bare-os/timers/*.timer.example` on the system image when present.
|
||||
- **System cron** — Optional image file `/etc/bare-os/crontab` (see [crontab.example](../kernel/etc/bare-os/crontab.example)) is merged with user crontab entries. Lines may use `@reboot` + command (once per `bare-cron` start) and optional `JitterSec=N` prefix on the command for calendar lines.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user