What's new in Bootgly 1.3
Bootgly 1.3 gives the event loop its own timers and signals, and adds S3 direct transfers, legacy password verifiers, SQL::transact() and a route list.
By Rodrigo de Araujo VieiraPublished 8 min read
Drafted with AI assistance; reviewed and edited by Rodrigo de Araujo Vieira.
Bootgly 1.3 is about the event loop: recurring timers, signal handlers and the framework's own periodic work now run on the built-in loop. Around it, the release adds S3 direct transfers, verifiers for passwords imported from another stack, a unit of work in one call for SQL, the Router's route list and a storage directory taken from the environment.
Every change and every commit is in the release notes.
Features
An event loop that owns its timers and signals
- Recurring timers. A loop that implements the new optional capability
ACI\Events\Repeating— the built-inSelectdoes — runs a callback every$intervalseconds withrepeat(float $interval, Closure $Callback, float $slack = 0.0): int, down to 1 ms, stopped with the samecancel()asdefer(). The schedule is a fixed grid, so it does not drift: a late run runs once and missed periods are skipped, and a callback that throws is reported and keeps its schedule. With aslack, timers start on shared instants and wake the loop once for all of them when their interval is a whole multiple of the slack. - Signal handlers on the loop. With the optional capability
ACI\Events\Signalling, also built intoSelect,trap(int $signal, Closure $Handler)runs a handler on the loop, between callbacks, each time the process receives the signal;untrap()anddestroy()put back what the process did before. The TCP, HTTP, WebSocket and UDP workers hand their server's signals to the loop and report a handler that throws instead of dying. - Stream readiness with a deadline.
ABI\Events\Selectorwaits on the monotonic clock:watch(),forget()andwait(null|int $deadline). A signal ends the wait with$interruptedset, and waiting again with the same deadline resumes it without extending it. Every refusal is named — a closed or descriptor-less stream, a descriptor at or aboveFD_SETSIZE, a stream closed while watched, an indefinite wait on nothing. - Sub-second SSE ticks.
open(Tick: …, interval: 0.1)runs theTickevery 100 ms on a loop timer of its own, whatever the heartbeat. Emitterlifecycle. One-shot listeners (listen(…, once: true)) andforget($Event, $Listener).- Liveness checks.
Connection::watch(int $interval, null|Closure $Check = null)gives a protocol its own liveness check on the worker's supervision sweep, on the built-in loop.
S3 direct transfers
- Presigned URLs.
S3::presign()lets its holderGET,HEADorPUTone object for up to 7 days, with no credentials; aPUTcan bindContent-Type,Content-Length,Content-MD5andx-amz-meta-*into the signature. - Multipart uploads from the browser.
$S3->Uploadscreates an upload, signs its parts, lists them, and completes or aborts it. A listing gives every part orfalse, never a partial list. - Ranged reads.
S3::read($path, $sink, int $offset = 0, null|int $length = null): no byte outside the window reaches the sink. - A public SigV4 signer,
S3\Signer.
These transfers are covered by the framework's own S3 test double and the published SigV4 vectors; this release was not exercised against a live bucket.
Passwords imported from another stack
new Password(Verifiers: [...]) reads hashes PHP cannot. Native formats always come first, and a hash that passes a verifier is rehashed with argon2id at that sign-in — Users::verify() persists it. Password\Verifiers\PBKDF2 reads <prefix><iterations>:<salt>:<key> rows.
A unit of work in one call
For commands, jobs and scripts, SQL::transact(Closure $Work): mixed begins, runs the work, commits every level left open and returns the result; a throwable rolls back level by level and is rethrown, and a failed COMMIT throws. On every way out, the connection is back in the pool. Nested units of work are savepoints of the same transaction, so a level that throws is rolled back alone.
The Router's route list
$Router->Routes is a read-only list of the registered routes, complete once the Router is warm: path with its group prefix, methods, handler, the middlewares dispatch runs around it, parameters, cache options and kind. Router::warm() warms the route cache without a request, so a test, a command or a tool can read the list.
The storage directory from the environment
BOOTGLY_STORAGE_DIR moves logs, PIDs, sessions, locks, queues and cache without a launcher of your own, and project <Name> startup writes it into the systemd units it generates. On the kit image, a storage volume the platform mounts empty and root-owned gets the image's layout on a root start.
Worker limits for Web apps
Web\App\Configs takes headroom, maxWorkerPendingBytes, maxRequests, jitter and maxMemory, and App::configure() forwards them to the HTTP server; out-of-range recycling options are refused.
Improvements
Performance
- Idle connections. On the built-in loop, the master watchdog, the recycle gate, the drain poll, every connection's idle expiration and the WebSocket heartbeat now ride one supervision sweep a second per worker — no timer per connection. With 10,000 idle connections on 16 workers, that is 20% less memory per connection, 18% less CPU to hold them and 37% less to expire them.
- SSE streams. The streams of a worker that share an interval come due on at most 16 instants per interval (
sse:1: 2,260 → 2,551 events/s delivered). Emitter. An event with no listener left goes back to its zero-cost path, and an emission with one listener costs about half of what it did.
Security
- S3. Credentials and option values that cannot travel in a header are refused before any request, header values are signed as SigV4 specifies, a listing that does not advance stops, the secret and the session token stay out of traces and dumps, and hostile XML answers (document types, non-UTF-8, over 32 MiB) are refused.
- Passwords.
Password\Verifiers\PBKDF2uses a constant-time comparison and an iteration ceiling that bounds what a tampered row can cost, and refuses at construction a prefix too long for any row. A verifier that throws fails the verification, is reported once, and never sees the password in a trace. - Storage directory.
BOOTGLY_STORAGE_DIRmust be an absolute, canonical path to a real directory nobody else controls or can replace; an unsafe or empty value stops the boot with one line on stderr and never falls back to the default. On the kit image, nothing changes owner recursively or through a link, andProcess\Servicerefuses an environment value systemd would drop (NUL, line break, non-UTF-8).
Fixes
- A route set registers once on a cold Router. A handler that registers with direct
route()calls runs again on every request while the Router is cold; each such run piled every dynamic route, group andintercept()middleware on top of the last — memory grew per request and a middleware ran once per earlier run. The server now rewinds a cold Router before each run, and a registration an earlier run made keeps everyintercept()middleware it had — the Router note under Upgrading lists the cases that still need care. - Out-of-band data no longer spins a worker. The built-in loop refuses
EVENT_EXCEPTregistrations: nothing consumed them, and out-of-band data made the worker spin at 100% CPU. - Every server logs what it catches. A failure handed to
Throwables::notify()— a signal handler, a recurring timer, a shutdown listener, a WebSocket message handler — reaches theexceptionslog channel on TCP, WebSocket and UDP servers too, not only on HTTP. - Synchronous signal delivery. Workers start with synchronous signal delivery; a worker forked in Monitor mode used to inherit asynchronous delivery.
IO\IPC\Pipe::reading()keeps reading after a timeout or a signal, where it ended withfalse; it yieldsnullon each timeout.
Upgrading
Before you upgrade, check the release-specific notes below: they can need an edit in your code or setup.
At the kit root:
bootgly kit upgrade v1.3.0
Running projects keep the code they loaded: stop them first or reload them after. Coming from a release older than v1.0.4, lay down the agent rules once afterwards (bootgly kit boot --agents); a kit older than v1.0.0-rc.1 has no kit upgrade yet, and the release notes show how to move it once by hand. With Docker, pull bootgly/bootgly.kit:1.3.0 and start it with the same volumes: a container run without one keeps nothing, and kit upgrade refuses inside the image — the image tag is the release.
Release-specific notes
- Routes registered on a cold Router. If a request handler registers routes with direct
$Router->route()calls, the routes of a run are now whole or nothing while the Router is cold: a handler that guards part of its routes to run once (astaticflag, arequire_once) while the rest runs on every request must drop the guard or guard everything.intercept()is now ignored on a warm Router, likeroute(). Avoid the two shapes the Router page lists that still lose a middleware intercepted on the first run only, and build once — outside the handler — a middleware made from the request or the time, or holding what the Router cannot compare (stdClass,PDO, the bundledAccessLog): built on every cold run, it is kept once per run. - Kit image volumes. A project whose server Configs demote to an account other than
bootglyis refused over a root-owned volume withoutsessions/, as it already was over the image's own storage: handlogs/andsessions/to that account on the volume once (the Docker guide has the command). - Worker timers and signals. On the built-in loop,
Timer::del()with no argument no longer stops the framework's own worker timers, and a blockingsleep()in a handler is no longer cut short every second by the alarm. A handler a server subclass installed before the fork for one of the server's own signals no longer runs in the workers. - New signatures for subclasses.
SSE::open()declaresint|float $interval;S3::read()takesint $offset = 0, null|int $length = null;Emitter\Listeners::add()takesbool $once = falseand$entriesis readable;Password::__construct()takesarray $Verifiers = [];Process\Servicedeclarespublic private(set) array $environment;SQLdeclarestransact();Select::$exceptsis gone andadd()/del()answerfalseforEVENT_EXCEPT. An override must match the new signature. IO\IPC\Pipe::reading()no longer ends at the first timeout: a consumer that relied on it leaves the loop withbreakon the firstnull.Transaction::begin()while its ownBEGINis in flight is refused: await it before the next operation.