NAME
Developer::Dashboard::Guide::Runtime - runtime lifecycle and state updates
DESCRIPTION
The runtime lifecycle: how the dashboard services run day to day, and how runtime state is updated.
This guide is part of the Developer::Dashboard manual. The main page is the front door for the whole set.

The four states of the web runtime, and the commands that move it between them.
Runtime Lifecycle
The runtime manager follows the older local-service pattern:
d2 servestarts the web service in the background by defaultOn POSIX, background web startup launches the private
web-foregroundhelper through GoRoutine's shell-free process API. The runtime records the listener only after the configured port accepts connections; if readiness times out, it terminates and reaps the child and reports its exit status and log paths.d2 servestarts the configured collector loops alongside the web service, so a plain serve keeps collectors and the web runtime under the same lifecycle actiond2 serve --foregroundkeeps the web service attached to the terminald2 serve --sslenables HTTPS in Starman with the generated local certificate and key, keeps that certificate on a browser-correct SAN profile covering localhost, loopback IPs, the concrete non-wildcard bind host, and any configuredweb.ssl_subject_alt_names, regenerates older dashboard certs when they are stale, redirects non-HTTPS requests to the matchinghttps://...URL, and reuses the saved SSL setting on laterd2 restartruns unless you override itIn SSL mode, the public frontend starts
web-ssl-backend-foregroundwith GoRoutine's shell-free OS-process API. Accepted client sockets are handled by GoRoutine routines using the 0.12 shared filehandle support; shutdown stops and waits for the backend process and drains client routine errors explicitly. If a client or listener socket close fails, the frontend retains the first close error, joins its workers, stops the managed backend, and then reports the saved error so cleanup is not abandoned at the first failed close.On Windows, saved-Ajax
stdoutandstderrpipes are drained by one Perl reader thread per pipe becauseIO::Selectcannot reliably report anonymous pipe readiness there. Chunks and read errors pass through a bounded event queue; interrupted reads are retried, and a disconnected writer or fatal stream error terminates the child and joins both readers before returning.d2 serve --no-editorandd2 serve --no-enditkeep the browser in read-only mode by hiding Share, Play, and View Source chrome, denying/app/<id>/edit,/app/<id>/source, and bookmark-save POST routes with403, and persisting that read-only flag for laterd2 restartruns untild2 serve --editorturns it back offd2 serve --no-indicatorsandd2 serve --no-indicatorkeep normal page rendering and left-side page chrome intact while clearing the whole top-right browser-only chrome area, including the status strip, username, host or IP link, and live date-time line, and persisting that flag for laterd2 restartruns untild2 serve --indicatorsturns it back offd2 serve logsprints the web-service runtime log captured in the d2 log file.-tprefixes lines with UTC timestamps,--tail N,--tail=N, and-n Nlimit the initial output, and-ffollows appended lines. For example,d2 serve logs -t --tail 100 -fstarts with the final 100 lines and then follows new output.d2 serve workers Nsaves the default Starman worker count and starts the web service immediately when it is currently stopped;--host HOSTand--port PORTcan steer that auto-start path, and bothd2 serve --workers Nandd2 restart --workers Ncan still override the worker count for one rund2 stopstops both the web service and managed collector loops and, prints the final lifecycle summary as a terminal table by default or JSON with-o json; on an interactive terminal it also prints the full stop task board onstderrbefore work starts so each shutdown step becomes visible instead of silent waiting.The shutdown path now also follows the saved managed listener port back to the real listener pid when the live web process has renamed itself into a
starman mastershape, so minimal Docker runs still stop the actual serving process instead of leaving the listener behind.Managed collector stop and restart flows also wait for the previous loop to really die before accepting a replacement, so a slow shutdown does not leave a stale collector process rewriting loop state while the next restart is proving the new pid.
d2 stop webonly stops the managed web serviced2 collector stoponly stops managed collector loopsd2 collector stop <name>only stops the requested managed collector loop, and collector-name shell completion suggests registered collector namesd2 restartstops both, starts configured collector loops again, then starts the web service, prints the final lifecycle summary as a terminal table by default or JSON with-o json, and only reports success after the replacement collector loops and web runtime become visible and survive a short post-ready confirmation window, with the web side still holding a live managed pid and an accepting listener on the requested port.Restart now also reuses the saved listener port to recover the real serving pid when the web process has renamed itself into the underlying
starman masterform, so container restarts still own and replace the active listener instead of losing control after startup. On Linux hosts that are also running Developer Dashboard inside Docker containers, managed stop and restart paths now reject sibling runtime pids that live in a different Linux pid namespace, so a host-side restart does not accidentally kill or adopt a container-owned web listener or collector loopd2 restart webonly restarts the managed web serviced2 collector restartonly restarts managed collector loopsd2 collector restart <name>only restarts the requested collector loop, including an on-demand manual collector by converting it into a managed interval loop, and collector-name shell completion suggests registered collector namesmanaged collector loops also run under a watchdog supervisor; if a loop dies unexpectedly after startup, the watchdog restarts it automatically, records the restart attempt in collector status/logs, and after too many crashes inside the watchdog window marks the collector
attention_requiredso the operator sees an explicit problem instead of infinite silent restart churnd2 logandd2 logsprint the combined dashboard web log plus collector logsd2 logs --tail 100ord2 logs --tail=100prints only the last 100 lines of the combined output. The same--tailoption accepts both spellings ford2 log web,d2 collector log, and a named collector log.-n Nremains a compatible short form.--tail=0prints no lines; negative or non-integer counts are rejected with usage information.-tprefixes each displayed line with a UTC timestamp. Collector output uses the recorded run timestamp; raw web output, which has no stored per-line event time, uses the time it is read.-ffollows new lines from web logs, one collector, all collectors, or the combined view. Flags may be combined, sod2 logs -f -t --tail 50starts with the last 50 combined lines and continues following both sources.d2 log webprints only the dashboard web log and supports-t,--tail N,--tail=N,-n N, and-fd2 collector logprints only collector logs and accepts-t,-f, and the same trailing-line limitd2 collector log <name>prints only the requested collector log, accepts-t,-f,--tail N, and--tail=N, and collector-name shell completion suggests registered collector namesinteractive restart and stop task boards mark the active step with a blue
-, stream active detail lines in blue, mark completed steps with a green[OK], mark failed steps with a red[X]plus red failure detail lines, keep the final table or JSON summary onstdout, and use numeric POSIX shutdown signals so minimal Alpine/iSH Perl builds that rejectTERMby name still terminate managed web and collector processes correctlyweb shutdown and duplicate detection do not trust pid files alone; they validate managed processes by environment marker or process title and use a
pkill-style scan fallback when neededWhen a collector pid file is missing, duplicate detection checks both the process table and the parent-written loop state. That state closes the short startup interval before a newly forked supervisor adopts its process title, so a concurrent start does not fork a second loop.
Updating Runtime State
Run your user-provided update command:
d2 update
If ./.developer-dashboard/cli/update or ./.developer-dashboard/cli/update/run exists in the current project it is used first; otherwise the home runtime fallback is used. d2 update runs that command after any sorted hook files from update/ or update.d.
Re-running d2 init keeps an existing ~/.developer-dashboard/config/config.json intact. If the file is missing, init creates it as {}. The command refreshes dashboard-managed helpers in ~/.developer-dashboard/cli/dd/ and preserves user-owned saved pages.
When d2 init refreshes a dashboard-managed helper or shipped starter file, it compares the existing content against the shipped content by MD5 inside Perl first. If the content already matches, init skips the copy instead of rewriting the file unnecessarily.
When bookmark HTML: or shared nav/*.tt fragments hit a Template Toolkit syntax error, render mode now shows a visible runtime-error block instead of leaking the raw [% ... %] source into the browser or d2 page render output.
Home helper staging is non-destructive too. d2 init may add or update dashboard-managed built-in helpers only under ~/.developer-dashboard/cli/dd/. User commands and hook directories stay in ~/.developer-dashboard/cli/ and in child-layer ./.developer-dashboard/cli/ roots, and init must not overwrite or delete those user-space files while refreshing the home-only dd namespace.
The public d2 entrypoint also stays thin for all built-in commands. It only stages and execs helper assets from share/private-cli/: dedicated helper bodies for d2 jq, d2 yq, d2 of, d2 open-file, d2 workspace, d2 path, d2 paths, d2 file, d2 files, and d2 ps1, plus thin wrappers for the remaining built-ins that hand off to the shared private _dashboard-core runtime.
The shipped starter bookmark source lives under share/seeded-pages/, and the shipped helper scripts live under share/private-cli/, so neither bookmark bodies nor helper script bodies are embedded directly in the command script. Installed copies resolve the same seeded pages and helper assets from the distribution share directory, so d2 init works after a cpanm install and not just from a source checkout.
Those helper-backed built-ins also rewrite their live process title to developer-dashboard ..., so process listings stay aligned with the public command names instead of exposing the staged helper path.
When d2 re-execs a Perl-backed helper or hook, it also forces the same active dashboard lib/ root into that child Perl process. That keeps thin switchboard handoff on the current checkout code instead of drifting onto an older installed Developer::Dashboard copy that may also be visible in PERL5LIB.
d2 cpan <Module...> installs optional Perl modules into the active runtime-local ./.developer-dashboard/local tree and appends matching requires 'Module'; lines to ./.developer-dashboard/cpanfile.
The command stays implemented in the d2 entrypoint rather than introducing a separate CPAN manager product module, and saved Ajax workers infer the same runtime-local local/lib/perl5 path directly from the active runtime root. When the requested modules include DBD::*, the command also installs and records DBI automatically so generic database driver requests work with a single command.

d2 serve reports the running app: its process, its port, and the collectors it supervises.

d2 doctor audits the runtime and reports every root it checked; this run is clean.