feat(installer): Lemonade daemon bootstrap (config + systemd unit) (PR-5)#159
Merged
Merged
Conversation
…R-5) Adds the `Lemonade daemon` install step after PR-4's system prerequisites and before PR-6's server_models.json block: * Pinned embeddable tarball (v10.6.0) — sha256 verified with `HAL0_SKIP_LEMONADE_SHA=1` escape hatch, extracted into /opt/lemonade/ with a `.installed-version` marker so re-runs skip the multi-hundred-MB download when the binary is already current. * Dedicated `hal0` system user/group (idempotent) — owns /opt/lemonade + /var/lib/hal0/lemonade so lemond runs unprivileged per ADR-0008 §1 (internal loopback-only runtime). * /var/lib/hal0/lemonade/config.json written atomically every run with the locked baseline from lemonade-adoption-plan §3 (config_version=1, port 13305 loopback, max_loaded_models=4, rocm_channel=stable, flm.args="--asr 1 --embed 1", kokoro cpu_bin=builtin, ...). * MANDATORY `llamacpp.args = "--parallel 1 --threads N"` per ADR-0008 §4 + memory `hal0_lemonade_threads_deadlock`. Formula: N = max(2, (nproc - 2) / 4) — splits across the four-process capability rollup (primary + embed + rerank + voice) and avoids the spike #2 Vulkan-dispatch deadlock. Defaults to 2 + warn when nproc is unavailable; the flag is never omitted. * /etc/systemd/system/hal0-lemonade.service — Type=simple, User=hal0, LimitMEMLOCK=infinity, CPUQuota=80%, ExecStop curl /internal/shutdown for clean drain. Verbatim from plan §3. * Service start block extended to `systemctl enable --now hal0-lemonade` before hal0-api, with a 30 s wait_active. * Full DEV_MODE skip with what-would-happen logging. * ERR-trap recovery hint for the new step. * UI_STEP_TOTAL bumped 9 → 10. Refs: lemonade-adoption-plan-2026-05-22 §3 / §11 PR-5 / §12.2-12.3, ADR-0008 §1, §3, §4, memory `hal0_lemonade_threads_deadlock`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-5 of the v0.2 Lemonade migration sequence. Layers the actual lemond
daemon bootstrap on top of PR-4's system prerequisites (#157), still
landing before PR-6's
server_models.jsongenerator block.Summary
HAL0_SKIP_LEMONADE_SHA=1escape hatch (mirrors PR-4's FLM .deb pinstyle), extracted to
/opt/lemonade/with a marker file so re-runsskip the ~200 MB download when the binary on disk already matches
LEMONADE_VERSION.hal0system user/group; owns/opt/lemonadeand/var/lib/hal0/lemonadeso lemond runs unprivileged per ADR-0008 §1(internal loopback-only runtime).
/var/lib/hal0/lemonade/config.jsonfrom the lockedbaseline in lemonade-adoption-plan §3 —
config_version=1, port13305 loopback,
max_loaded_models=4,rocm_channel="stable",flm.args="--asr 1 --embed 1",kokoro.cpu_bin="builtin", etc.llamacpp.args = "--parallel 1 --threads N"perADR-0008 §4 + memory
hal0_lemonade_threads_deadlock. Formula:N = max(2, (nproc - 2) / 4)— splits across the four-processcapability rollup (primary + embed + rerank + voice) and avoids the
spike fix(ci): clear ruff lint + format errors blocking CI #2 Vulkan-dispatch deadlock. Defaults to 2 + warn when nproc
is unavailable; the
--threadsflag is never omitted./etc/systemd/system/hal0-lemonade.serviceverbatim from plan §3(
Type=simple,User=hal0,LimitMEMLOCK=infinity,CPUQuota=80%,ExecStop=/usr/bin/curl ... /internal/shutdown).systemctl enable --now hal0-lemonadebefore hal0-api, with a 30 swait_active. Softon failure — hal0-api still boots + surfaces the dead-lemond banner.
DEV_MODEskip with what-would-happen logging.UI_STEP_TOTALbumped 9 → 10.Scope
File touched: only
installer/install.sh(+298 / -1). PR-4's sectionand PR-6's
server_models.jsonblock are untouched.Refs
docs/internal/lemonade-adoption-plan-2026-05-22.md§3 (servicetopology + verbatim config.json + unit baseline), §11 PR-5,
§12.2 (port 13305 loopback), §12.3 (version pinning).
docs/internal/adr/0008-lemonade-adoption.md§1 (single lemond,loopback), §3 (per-type LRU), §4 (mandatory
--threads N).hal0_lemonade_threads_deadlock— non-negotiableoperational constraint; spike fix(ci): clear ruff lint + format errors blocking CI #2 differential matrix.
Test plan
bash -n installer/install.shclean.shellcheck installer/install.sh— no new findings; pre-existingSC1091/SC2018/SC2019info-level only..venv/bin/python -m pytest tests/ -q— 1479 passed, 8 skipped,3 xfailed (pre-existing).
.venv/bin/ruff check src tests— all checks passed..venv/bin/ruff format --check src tests— 245 files formatted.sudo bash installer/install.shon hal0 LXC 105 oncePR-6/PR-7 land and the config schema settles (real fixture).
LEMONADE_SHA256from the all-zeros placeholder before v0.2tag.
🤖 Generated with Claude Code