Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
update.sh: a failed update is down for about two minutes, not seven
milind-soni4efc6f4ef361
diff --git a/apps/docs/content/docs/self-hosting/deploy-vps.mdx b/apps/docs/content/docs/self-hosting/deploy-vps.mdxindex f695fbb922..de2de8b7dd 100644--- a/apps/docs/content/docs/self-hosting/deploy-vps.mdx+++ b/apps/docs/content/docs/self-hosting/deploy-vps.mdx@@ -327,13 +327,22 @@ every file's owner and mode either way. The script then:has matched. The server is down from here until step 4; how long dependson how much data there is.3. Writes the image into `.env` (`OMB_IMAGE=ghcr.io/milind-soni/openmausbot@sha256:…`)- and starts it.-4. Waits, up to five minutes, until the new server answers `/api/health`+ and starts it. An install the installer made while Caddy still shared the+ server's network gets the installer's current `compose.yaml` and+ `Caddyfile` here, as a run of the installer would write them (the rollback+ puts the old ones back). For this repository's `docker-compose.yml`,+ `git pull` brings the current one; `--check` says when it is needed.+4. Waits, up to two minutes (`OMB_UPDATE_WAIT_S` for longer), until the new server answers `/api/health`steadily, says it is the new version, can still start a bot if it could- before (`openmausbot doctor`: an engine is ready), and Caddy runs again.+ before (the server's own count of ready engines, `GET /api/health/engines`,+ which a hardened server answers too; `openmausbot doctor` on a version+ without it), and Caddy runs again.5. If any of that fails: puts back the data from the copy, `.env` and the oldimage, starts the old version, and tells you what went wrong. Your server- is as it was before step 1. The copy is put into a new folder inside the+ is as it was before step 1, except that `.env` now names the old version by+ its digest: a tag such as the installer's `stable` may have moved since,+ and a later run of the installer would otherwise follow it. `--rollback`+ does the same. The copy is put into a new folder inside thedata and checked there before it takes the data's place, so a restore thatfails (a full disk, say) leaves both the data and the copy as they were:the server stays stopped, the update's journal is kept, anddiff --git a/deploy/update.sh b/deploy/update.shindex 8bc5ee0694..f0b39ca4f9 100755--- a/deploy/update.sh+++ b/deploy/update.sh@@ -37,7 +37,9 @@ PINNED="^ghcr\.io/milind-soni/openmausbot@sha256:[0-9a-f]{64}$"STABLE_URL=${OMB_STABLE_URL:-https://raw.githubusercontent.com/milind-soni/OpenMausBot/channels/stable.json}NEWEST_URL=${OMB_NEWEST_URL:-https://api.github.com/repos/milind-soni/OpenMausBot/releases/latest}SERVICE=${OMB_UPDATE_SERVICE:-omb}-WAIT_S=${OMB_UPDATE_WAIT_S:-300}+# A healthy server answers within seconds of starting; two minutes leaves room for a slow first start after an update,+# and is how long the server is down before a version that never answers is rolled back. OMB_UPDATE_WAIT_S for more.+WAIT_S=${OMB_UPDATE_WAIT_S:-120}ENGINE_WAIT_S=${OMB_UPDATE_ENGINE_WAIT_S:-120}POLL_S=${OMB_UPDATE_POLL_S:-5}KEEP_TAG="openmausbot-before-update:local"@@ -352,9 +354,11 @@ services:ports:- "80:80"- "443:443"+ # Started with the server, not after it is healthy: Caddy reaches it over the socket+ # whenever it answers, so `up` never waits on the server's health.depends_on:omb:- condition: service_healthy+ condition: service_startedenvironment:DOMAIN: ${DOMAIN}volumes:@@ -802,8 +806,9 @@ if old_installer_layout; thenelse roll_back "The installer's compose.yaml and Caddyfile could not be rewritten (see $LOG)." 1; fifipin_image "$J_target"-# Where Caddy waits for a healthy server, `up` itself fails when the new version never gets there; the wait below-# then says why.+# Where Caddy waits for a healthy server (a Compose file from before Caddy had its own container), `up` itself waits,+# and fails when the new version never gets there; the wait below then says why. The current files start Caddy with+# the server, so `up` returns at once and the wait below is the only one.if ! compose up -d --no-build >>"$LOG" 2>&1 && [ "$(inspect '{{.Image}}' "$(container)")" != "$J_target_id" ]; thenroll_back "Docker could not start $(new_name) (see $LOG)." 1fidiff --git a/docs/deploy-vps.md b/docs/deploy-vps.mdindex 7ff733964e..148d2764e9 100644--- a/docs/deploy-vps.md+++ b/docs/deploy-vps.md@@ -307,13 +307,22 @@ every file's owner and mode either way. The script then:has matched. The server is down from here until step 4; how long dependson how much data there is.3. Writes the image into `.env` (`OMB_IMAGE=ghcr.io/milind-soni/openmausbot@sha256:…`)- and starts it.-4. Waits, up to five minutes, until the new server answers `/api/health`+ and starts it. An install the installer made while Caddy still shared the+ server's network gets the installer's current `compose.yaml` and+ `Caddyfile` here, as a run of the installer would write them (the rollback+ puts the old ones back). For this repository's `docker-compose.yml`,+ `git pull` brings the current one; `--check` says when it is needed.+4. Waits, up to two minutes (`OMB_UPDATE_WAIT_S` for longer), until the new server answers `/api/health`steadily, says it is the new version, can still start a bot if it could- before (`openmausbot doctor`: an engine is ready), and Caddy runs again.+ before (the server's own count of ready engines, `GET /api/health/engines`,+ which a hardened server answers too; `openmausbot doctor` on a version+ without it), and Caddy runs again.5. If any of that fails: puts back the data from the copy, `.env` and the oldimage, starts the old version, and tells you what went wrong. Your server- is as it was before step 1. The copy is put into a new folder inside the+ is as it was before step 1, except that `.env` now names the old version by+ its digest: a tag such as the installer's `stable` may have moved since,+ and a later run of the installer would otherwise follow it. `--rollback`+ does the same. The copy is put into a new folder inside thedata and checked there before it takes the data's place, so a restore thatfails (a full disk, say) leaves both the data and the copy as they were:the server stays stopped, the update's journal is kept, and