Skip to content

feat(persistence): add backend state persistence to /data/state.json for StartOS backups - #2

Closed
heatpunk wants to merge 1 commit into
Start9-Community:mainfrom
heatpunk:feat/backend-state-persistence
Closed

feat(persistence): add backend state persistence to /data/state.json for StartOS backups#2
heatpunk wants to merge 1 commit into
Start9-Community:mainfrom
heatpunk:feat/backend-state-persistence

Conversation

@heatpunk

Copy link
Copy Markdown

Summary

  • Implements REST endpoints (GET /api/state, POST /api/state, DELETE /api/state) in production server (server/serve.cjs) to persist state to /data/state.json.
  • Updates Zustand store (src/store/miners.ts) with custom async storage adapter to sync state with backend.
  • Ensures miner configuration and app preferences are preserved across StartOS volume backups (Backups.ofVolumes('main')).

…for StartOS backups

- Implement GET /api/state and POST /api/state in production server (server/serve.cjs) to persist state to /data/state.json
- Update Zustand store (src/store/miners.ts) with custom async storage adapter to sync state with backend
- Ensure miner configuration and app preferences are included in StartOS volume backups
@helix-nine

helix-nine commented Jul 31, 2026

Copy link
Copy Markdown

Merged into #1, which is the packaging audit branch — thanks, this is exactly the gap that audit turned up.

Two things I fixed on the way in, worth knowing for next time:

  • pnpm-lock.yaml — dropped. This repo is npm: package-lock.json is the lockfile, and both the Dockerfile and CI run npm ci. A second lockfile from a different package manager just invites the two to drift.
  • npm run lint was failing — the four bare catch (_) {} blocks in the storage adapter are hard no-empty errors, and ci.yml runs lint on every PR. Changed to optional catch bindings with a short note on why each failure is safe to swallow.

The implementation itself looks right: /api/state is matched before the /api/ proxy passthrough, writes go through tmp+rename so a crash can't truncate the file, and a missing file returns {}.

One heads-up on rollout: this is application code baked into the container, and the manifest pins the currently published tag, which predates it. Verified against a live install — GET /api/state returns 404 and /data is still empty. So it does nothing until a new image is published and we bump dockerTag. If you cut a release with this in it, ping us and we'll bump the tag, update the backup docs, and re-test.

Also worth flagging for whenever this goes live: miner API passwords currently live only in the browser. Once state moves to /data/state.json they are on disk in plaintext and included in StartOS backups. Not a blocker, but it should be called out in the docs when it ships.

Closing this one since the commits are carried in #1.

@helix-nine helix-nine closed this Jul 31, 2026
@helix-nine

Copy link
Copy Markdown

One more thing, and it's a single job on your side.

Right now this doesn't change anything for StartOS users yet. StartOS installs a prebuilt Blisspoint, and the one it installs today was built before your change — so there's still nowhere for it to save to. We checked it on a real server to be sure.

What we need from you: make a new Blisspoint release with this included, then tell us it's out. That's the whole ask.

Once it exists we'll:

  1. Point the StartOS package at the new version.
  2. Update the text that currently warns people their miner list isn't included in backups.
  3. Install it and confirm a backup and restore really does bring the miners back.

Thanks for turning this around so quickly — it closes the one real gap the review turned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants