{"record":{"id":"5d02bd6bcbe31688","repo":"MemPalace/mempalace","slug":"daemon-is-not-running-job-args-job-id-is-job","errorCode":null,"errorMessage":"daemon is not running; job {args.job_id} is {job['state']}","messagePattern":"daemon is not running; job (.+?) is (.+?)","errorType":"exception","errorClass":"DaemonError","httpStatus":null,"severity":"error","filePath":"mempalace/cli.py","lineNumber":1300,"sourceCode":"                    jobs = [\n                        job_to_dict(job, include_payload=False)\n                        for job in QueueStore(qpath).list(args.limit)\n                    ]\n            for job in jobs:\n                print(f\"{job['id']}  {job['state']:<9}  {job['kind']:<10}  {job['created_at']}\")\n            return\n\n        if action == \"wait\":\n            client = get_client_if_running(palace_path)\n            if client is not None:\n                job = client.wait(args.job_id)\n            else:\n                qpath = queue_path(palace_path)\n                if not qpath.exists():\n                    raise DaemonError(\"daemon is not running\")\n                job = job_to_dict(QueueStore(qpath).get(args.job_id))\n                if job.get(\"state\") not in TERMINAL_STATES:\n                    raise DaemonError(f\"daemon is not running; job {args.job_id} is {job['state']}\")\n            result = job.get(\"result\") or {}\n            from .service import print_job_result\n\n            exit_code = print_job_result(result)\n            if job.get(\"state\") != \"succeeded\" and exit_code == 0:\n                print(f\"mempalace: daemon job failed: {job.get('error')}\", file=sys.stderr)\n                exit_code = 1\n            if exit_code:\n                sys.exit(exit_code)\n            return\n    except DaemonError as exc:\n        print(f\"mempalace: daemon error: {exc}\", file=sys.stderr)\n        sys.exit(1)\n\n\ndef cmd_search(args):\n    from .searcher import search, SearchError\n","sourceCodeStart":1282,"sourceCodeEnd":1318,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/cli.py#L1282-L1318","documentation":"Raised by the CLI job 'wait' fallback path when the daemon is not running but the job still exists in the persisted queue store in a non-terminal state (not in TERMINAL_STATES). Because no daemon is alive to advance the job, waiting is impossible, so the CLI refuses rather than hang. The message includes the job id and its current state (e.g. 'queued' or 'running').","triggerScenarios":"Running the job wait action when get_client_if_running() returns None (daemon down), queue_path(palace_path) exists, QueueStore.get(job_id) succeeds, but job['state'] is not a terminal state — i.e. the daemon died or was stopped mid-job.","commonSituations":"Daemon crashed or was killed while a job was queued/running; machine rebooted mid-job; user manually stopped the daemon then tried to wait on the in-flight job; stale queue left behind after an unclean shutdown.","solutions":["Restart the daemon so it resumes processing the queue, then re-run wait","Inspect the job state with the list action to decide whether to cancel/retry the stuck job","If the daemon is crashing repeatedly, check daemon logs for the underlying failure before retrying","If the job is wedged in a non-terminal state and the daemon will not resume it, cancel or re-enqueue it"],"exampleFix":"# before\nmempalace job wait abc123   # -> daemon is not running; job abc123 is running\n\n# after\nmempalace daemon start   # daemon resumes the queue\nmempalace job wait abc123","handlingStrategy":"retry","validationCode":"client = get_client_if_running(palace_path)\nif client is None:\n    job = job_to_dict(QueueStore(queue_path(palace_path)).get(job_id))\n    if job.get(\"state\") not in TERMINAL_STATES:\n        # daemon died mid-job: restart it instead of waiting\n        start_daemon()  # resumes the queue\n        client = get_client_if_running(palace_path)","typeGuard":null,"tryCatchPattern":"try:\n    wait_job(job_id)\nexcept DaemonError as exc:\n    if \"is\" in str(exc) and str(exc).split()[-1] in {\"queued\", \"running\"}:\n        restart_daemon_and_wait_again(job_id)  # one bounded retry\n    else:\n        raise","preventionTips":["Run the daemon under a supervisor (systemd, launchd) so it restarts after crashes","After any daemon stop/crash, drain or cancel non-terminal jobs before issuing new waits","Check job list output for stuck non-terminal states after unclean shutdowns"],"tags":["cli","daemon","jobs","mempalace"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}