Files
clawmates/deploy/clawmates-runtime/clawmates-runtime.service
T
Omar Sobh a1d1097b52
ci / gates (push) Successful in 5s
ci / frontend (push) Successful in 26s
ci / rust (push) Successful in 4m27s
ci / e2e (push) Skipped
ci / publish (push) Successful in 3m39s
ci + ops: cargo-build retry wrapper + runtime systemd unit
Two durability fixes closing recurring flakes:

CI flake wrapper (broker + server Dockerfiles):
  Wrapped the cargo build step in a 3-attempt retry loop with
  linear backoff (10s / 20s). Directly targets the crates.io
  transient network errors that keep hitting CI on the runners
  ('curl failed: SSL_ERROR_SYSCALL, errno 0'). Each build only
  loses time on transient failures; a real compile error still
  fails all 3 attempts and surfaces the last error normally.

Runtime systemd unit (deploy/clawmates-runtime/):
  Replaces the manual 'docker run' that had been starting the
  ZeroClaw runtime with no persistence for its network topology.
  Ephemeral prod fixes at 09:30 PDT 2026-07-21 (task #38) were:
    - anthropic.default provider block added to
      /root/clawmates-runtime/data/.zeroclaw/config.toml (already
      durable — bind-mounted from host)
    - docker network connect clawmates_edge clawmates-runtime
      (NOT durable — vanishes on container recreate)
  New systemd unit clawmates-runtime.service (installed +
  enabled on gw-04):
    - ExecStart docker-runs the container attached to
      clawmates_core, then connects clawmates_edge in the same
      shell command, then docker waits.
    - Bind-mounts both /root/clawmates-runtime/data and
      /var/lib/clawmates-missions (for security_scan +
      benchmark_runner).
    - --rm so upgrading is just docker pull + systemctl restart.
    - Restart=on-failure with 5s backoff.

Closes task #38 and preemptively closes the CI flake pattern.
2026-07-21 12:53:30 -07:00

46 lines
1.5 KiB
Desktop File

[Unit]
Description=Clawmates ZeroClaw runtime (missions execution)
Documentation=https://github.com/openclaw/openclaw
After=docker.service network-online.target
Wants=network-online.target
Requires=docker.service
[Service]
Type=simple
Restart=on-failure
RestartSec=5
TimeoutStartSec=120
# ─── State
# clawmates_core: internal, holds server ↔ runtime traffic
# clawmates_edge: has egress, needed for outbound calls to
# api.anthropic.com, generativelanguage.googleapis.com,
# api.groq.com, etc.
# /root/clawmates-runtime/data → /zeroclaw-data (config + brains)
# /var/lib/clawmates-missions → mirror path so security_scan +
# benchmark_runner can docker-exec here.
#
# The container is created fresh every start (--rm) and cleaned on
# stop, so upgrading the image is a simple `docker pull` + systemctl
# restart.
Environment=IMAGE=clawmates-runtime:sync
Environment=NAME=clawmates-runtime
ExecStartPre=-/usr/bin/docker rm -f ${NAME}
ExecStart=/bin/sh -c '\
/usr/bin/docker run -d --rm --name ${NAME} \
--network clawmates_core \
--restart no \
-v /root/clawmates-runtime/data:/zeroclaw-data \
-v /var/lib/clawmates-missions:/var/lib/clawmates-missions \
${IMAGE} daemon --host 0.0.0.0 \
&& sleep 2 \
&& /usr/bin/docker network connect clawmates_edge ${NAME} \
&& /usr/bin/docker wait ${NAME}'
ExecStop=-/usr/bin/docker stop --time 10 ${NAME}
[Install]
WantedBy=multi-user.target