MemPalace/mempalace · error · DaemonError

daemon is not running

Error message

daemon is not running

What it means

Raised by the CLI's job 'wait' action when no daemon is running and there is no persisted queue store under the palace path. The wait command first tries to attach to a live daemon via get_client_if_running(); when that returns None it falls back to reading the job from disk, but a missing queue_path means the job was never queued locally. It surfaces as a DaemonError printed as 'mempalace: daemon error: ...' and a non-zero exit.

Source

Thrown at mempalace/cli.py:1297

                if not qpath.exists():
                    jobs = []
                else:
                    jobs = [
                        job_to_dict(job, include_payload=False)
                        for job in QueueStore(qpath).list(args.limit)
                    ]
            for job in jobs:
                print(f"{job['id']}  {job['state']:<9}  {job['kind']:<10}  {job['created_at']}")
            return

        if action == "wait":
            client = get_client_if_running(palace_path)
            if client is not None:
                job = client.wait(args.job_id)
            else:
                qpath = queue_path(palace_path)
                if not qpath.exists():
                    raise DaemonError("daemon is not running")
                job = job_to_dict(QueueStore(qpath).get(args.job_id))
                if job.get("state") not in TERMINAL_STATES:
                    raise DaemonError(f"daemon is not running; job {args.job_id} is {job['state']}")
            result = job.get("result") or {}
            from .service import print_job_result

            exit_code = print_job_result(result)
            if job.get("state") != "succeeded" and exit_code == 0:
                print(f"mempalace: daemon job failed: {job.get('error')}", file=sys.stderr)
                exit_code = 1
            if exit_code:
                sys.exit(exit_code)
            return
    except DaemonError as exc:
        print(f"mempalace: daemon error: {exc}", file=sys.stderr)
        sys.exit(1)

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Start the daemon (e.g. the daemon/service start subcommand) and re-run the wait command
  2. Verify you are pointing at the right palace: check the --palace path argument matches where the job was enqueued
  3. Confirm the job was actually created first with the job list action; if the queue file does not exist, no job was ever queued in this palace
  4. If the queue store was deleted accidentally, re-enqueue the work and retry

Example fix

# before
mempalace job wait abc123   # daemon not running, no queue file

# after
mempalace daemon start
mempalace job wait abc123
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
from mempalace.cli import queue_path  # or recompute: palace_path / "queue"

# Before `job wait`: daemon running OR queue store present
client = get_client_if_running(palace_path)
if client is None and not queue_path(palace_path).exists():
    raise SystemExit("daemon is not running and no queue exists; start the daemon first")

Try / catch

try:
    run_wait_action(args)
except DaemonError as exc:
    # covers both 'daemon is not running' variants
    print(f"daemon unavailable: {exc}", file=sys.stderr)
    sys.exit(1)  # or start daemon and retry once

Prevention

When it happens

Trigger: Running the CLI job wait subcommand (e.g. `mempalace job wait <job_id>` or the equivalent action dispatcher in cli.py) when: (a) the daemon process is not running, and (b) queue_path(palace_path) does not exist on disk — typically because no job was ever enqueued in this palace.

Common situations: Calling wait with a job_id from a different palace path (--palace pointing elsewhere); the daemon crashed and its queue directory was cleaned up; running wait before ever starting the daemon or enqueueing a job; fresh machine/clone with no ~/.mempalace state.

Related errors


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/21c9882f60e2b1dd. Report an issue: GitHub.