Phase 6d: systemd user unit for persistent FUSE mount #75

Merged
osobh merged 1 commits from phase-6d-fuse-systemd into main 2026-07-14 19:29:38 +00:00
2 changed files with 72 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
# deploy/systemd
Systemd **user** units for clawstor.
## Units
| Unit | Purpose |
|---|---|
| `clawstor-cluster.service` | daemon (gossip + RPC + Prometheus + build cache). Not shipped here — deployed per-node from the fleet playbook. |
| `clawstor-fuse.service` | Phase 6 read-only FUSE mount at `~/clawstor-mount/`. Depends on `clawstor-cluster.service`. |
## Install `clawstor-fuse.service`
Prereqs: `libfuse3` installed, `claw-fuse` binary built with
`cargo build --release --features fuse --bin claw-fuse`.
```bash
# 1. Copy the binary
cp target/release/claw-fuse ~/clawstor-deploy/claw-fuse
# 2. Install the unit
mkdir -p ~/.config/systemd/user
cp deploy/systemd/clawstor-fuse.service ~/.config/systemd/user/
# 3. Reload + enable
systemctl --user daemon-reload
systemctl --user enable --now clawstor-fuse.service
# 4. Verify
systemctl --user status clawstor-fuse.service
ls ~/clawstor-mount/ # blobs snapshots tags
```
Override the default paths with a drop-in:
```bash
systemctl --user edit clawstor-fuse.service
```
```ini
[Service]
Environment=CLAWSTOR_MOUNT=/mnt/clawstor
```
+29
View File
@@ -0,0 +1,29 @@
[Unit]
Description=Clawstor read-only FUSE mount (blobs / snapshots / tags)
Documentation=https://git.redclaw.dev/clawverse/clawstor
After=clawstor-cluster.service network-online.target
Wants=clawstor-cluster.service
[Service]
Type=simple
# Override via `systemctl --user edit clawstor-fuse.service` when the
# install lives elsewhere.
Environment=CLAWSTOR_FUSE_BIN=%h/clawstor-deploy/claw-fuse
Environment=CLAWSTOR_DATA=%h/clawstor-deploy/data
Environment=CLAWSTOR_MOUNT=%h/clawstor-mount
# Create the mount point if missing (idempotent). ExecStartPre runs
# BEFORE the actual mount; fusermount3 needs an existing dir.
ExecStartPre=/bin/mkdir -p ${CLAWSTOR_MOUNT}
# Best-effort pre-unmount in case a prior instance left a stale
# mount (e.g. daemon SIGKILL). fusermount3's `-u -z` = lazy detach,
# harmless when nothing is mounted.
ExecStartPre=-/usr/bin/fusermount3 -u -z ${CLAWSTOR_MOUNT}
ExecStart=${CLAWSTOR_FUSE_BIN} --data-dir ${CLAWSTOR_DATA} --mount ${CLAWSTOR_MOUNT}
# The FUSE binary blocks until unmounted. On systemd stop, send
# SIGTERM which fuser translates to a clean unmount.
ExecStop=/usr/bin/fusermount3 -u ${CLAWSTOR_MOUNT}
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target