Command Palette

Search for a command to run...

Back to skills
skill № 69423

systemd-live-dev

Long-lived BAS dev stack via systemd user units (not Docker): install units, restart after code changes, journalctl for errors, health curls between wakes…

FreeNo executable scripts
bbartlingby bbartling★ 20 GitHub stars

Install systemd-live-dev in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

systemd live dev (not Docker)

Default runtime

  • Do not use Docker Compose as the primary long-lived runtime unless BUILD_CHECKPOINTS explicitly requires it.
  • Use systemd user units bas-backend.service and bas-frontend.service (create frontend unit if missing — remote UI needs :5173).
  • Source of truth for commands and ports: bas_app/README.md § Run (not old templates that assumed uvicorn + bas_app_backend).

Canonical unit files (this repo’s bas_app layout)

Install copies under ~/.config/systemd/user/. After edits: systemctl --user daemon-reload then restart each changed unit.

bas-backend.service

Must match cd /home/ben/bas_app && python3 -m backend (stdlib package backend with __main__.py). Wrong: WorkingDirectory=/home/ben/bas_app/backend + python3 -m bas_app_backend + PYTHONPATH=src — that produces No module named bas_app_backend and empty :8000.

[Unit]
Description=BAS head-end API (bas_app stdlib backend)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/home/ben/bas_app
Environment=BAS_BIND_HOST=0.0.0.0
Environment=BAS_BIND_PORT=8000
# When UI is loaded from the LAN IP, include that Origin (comma list replaces defaults — add loopback too).
Environment=BAS_ALLOWED_ORIGINS=http://127.0.0.1:5173,http://localhost:5173,http://<head-end-ip>:5173
ExecStart=/usr/bin/python3 -m backend
Restart=on-failure
RestartSec=3

[Install]
WantedBy=default.target

bas-frontend.service

Must match cd /home/ben/bas_app/frontend && python3 -m http.server 5173 --bind 0.0.0.0.

[Unit]
Description=BAS static frontend (http.server)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/home/ben/bas_app/frontend
ExecStart=/usr/bin/python3 -m http.server 5173 --bind 0.0.0.0
Restart=on-failure
RestartSec=3

[Install]
WantedBy=default.target

Anti-drift checklist (run after any backend layout change)

Symptom Likely cause
No module named bas_app_backend in journal Unit still points at old FastAPI / src layout
curl http://127.0.0.1:8000/health fails Backend not started or wrong WorkingDirectory
UI static but login never works from LAN :8000 down; UI alone is not enough
Wake log: post_wake_stack: skip (no …/backend yet) but backend/app.py exists Default bas_post_wake_stack.sh gate does not match this tree — Codex does not depend on patching it: ship bas_app/scripts/ + README “headless start” and/or point POST_WAKE_HOOK at that script until ops upgrades the hook
post_wake starts uvicorn app.main:app and dies Hook command does not match stdlib python3 -m backend — same: Path B in BUILD_CHECKPOINTS.md

bas_post_wake_stack.sh (optional hook; not Codex’s only lever)

  • May skip or use the wrong start command for this repo’s stdlib layout. Policy: Codex delivers bas_app/README.md + bas_app/scripts/ parity so humans/cron can POST_WAKE_HOOK=bash /home/ben/bas_app/scripts/<your>.sh without editing bas_build_spec binaries.

Codex / cron wake shells and systemctl --user

Symptom: Failed to connect to bus: No medium found (or Connection refused to session bus) when running systemctl --user, journalctl --user, or systemctl --user cat … from bas_wake.sh → codex exec.

Why: User systemd --user talks to $XDG_RUNTIME_DIR/systemd/private (usually /run/user/<UID>). Cron and non-interactive Codex shells often have no XDG_RUNTIME_DIR / DBUS_SESSION_BUS_ADDRESS, and there may be no active logind session for that UID when the job fires — so there is literally no user manager bus in that environment. This is normal, not a broken app.

What Codex should do (in order):

  1. Detect: UID=$(id -u); test -d "/run/user/$UID" && echo "runtime_dir_ok" || echo "runtime_dir_missing".
  2. If runtime_dir_ok: prepend commands with XDG_RUNTIME_DIR=/run/user/$UID (and optionally DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus if the socket exists):
    XDG_RUNTIME_DIR=/run/user/$(id -u) systemctl --user daemon-reload
    XDG_RUNTIME_DIR=/run/user/$(id -u) systemctl --user restart bas-backend.service bas-frontend.service
  3. If runtime_dir_missing: do not treat “systemctl failed” as proof the unit file is wrong. Document for operators in bas_app/README.md:
    • sudo loginctl enable-linger <username> once (keeps [email protected] and /run/user/UID after boot and without GUI login).
    • Or run systemctl --user … from an SSH login as that user (interactive session creates the bus).
  4. Always verify the stack with Path-agnostic checks that work from cron: ss -ltnp, curl http://127.0.0.1:8000/health. If these pass, the product is up
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the systemd-live-dev skill do?

Long-lived BAS dev stack via systemd user units (not Docker): install units, restart after code changes, journalctl for errors, health curls between wakes. Triggers on: systemd, user unit, bas-backend, bas-frontend, journalctl, crash-loop, No module named, POST_WAKE_HOOK, bas_post_wake_stack, 8000, 5173, remote dial-in, WorkingDirectory, python3 -m backend, No medium found, XDG_RUNTIME_DIR, loginctl enable-linger, codex exec, cron wake shell.

How do I install the systemd-live-dev skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the systemd-live-dev skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare systemd-live-dev with