Skip to content

Build1 publisher3 min readPublished

Four conditions gate every emergency container this watchdog is allowed to start

Guard layers stop a self-hosted agent from doing damage, but not the container that exits on its own at 00:30, and one operator handles that with three bash scripts and a hard limit of three repair attempts.

The Engineer · Build desk

Illustration accompanying Four conditions gate every emergency container this watchdog is allowed to start

What happened

  • An open source trend radar showed hermes-agent, a self-hosted customizable AI assistant, picking up more than eight thousand GitHub stars in seven days.
  • The author of a dev.to post runs 84 containers on two servers as a one-person company, with agents that write code, migrate databases and answer support tickets at night.
  • At 00:30 his monitoring loop logged a load average of 33.59 on a machine that normally sits around four, traced it to one container in a tight loop, and had every category green again at the 01:00 scan.
  • The recovery layer is three bash scripts totalling just over a thousand lines, and he writes that every line exists because of a real incident.
  • live-app-watchdog.sh, at 289 lines, compares container state, domain health and declared target state every few minutes around the clock for every customer-facing app.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • constraint A guard layer covers only the damage an agent causes, so nothing in a self-hosted install owns the exits, exhausted pools and load spikes.
  • exposure This design accepts a degradation window of about half an hour, since detection and the all-green confirmation sat thirty minutes apart on the night in the journal.
  • decision Anyone copying the bridge-container trick inherits an open incident until a real deployment lands, because the cached-image container is defined as a bandage.
  • cost Adopting that bandage path costs a locally retained image verified by digest and configuration plus a deployment-window state the script can read. Without both, the watchdog cannot safely start anything.

live-app-watchdog.sh is allowed to start an emergency container only when four things are true at once. No healthy backend is serving the domain, no deployment or maintenance window is active, the locally retained image has been verified by digest and configuration, and an exclusive lock is held so two watchdog runs cannot start two bridges [10]. The lock came out of an incident. Two overlapping runs each decided the app was down, each started a container, and the proxy had two backends running different code [11]. "The lock is one line. It is the most important line in the file," the post says [12]. That condition travels only as far as the lock's scope, and two watchdog processes on one box are a different problem from two hosts that can each serve the same domain.

post-deploy-repair-loop.sh is the tightest of the three at 187 lines because it fires immediately after every deployment, and a bad pattern there would spread across thirteen apps before lunch [13]. It runs an HTTP check, then a visual check on whether the rendered page looks right and not only whether it returned 200. Then a fix from a short list of known remediations, then the checks again, three iterations at most [14]. The ceiling is in the file as max_attempts=3 [15]. When the budget is spent the script stops, marks the incident open and wakes a human after the third attempt [7]. The alternative the post documents is a well-meant loop that restarted the same container forty times while the actual cause was a full disk [6].

The two named scripts account for 476 lines of the just-over-a-thousand-line total, which leaves roughly 530 for the third; the excerpt breaks off before naming it [1]. The spike the monitoring loop caught was a load average of 33.59 against a normal of about four, roughly eight times normal [4][2].

For the 01:00 all-green to mean anything on someone else's box, a few things have to hold. Deployments have to leave a window state the watchdog can read, and images have to be retained locally and checkable by digest, or the script cannot safely start anything [10]. Half an hour of degradation has to be acceptable for whatever is degraded [3]. The author reads the incident at breakfast, and the entry sits in an operations journal, timestamped, with the load numbers and the action taken [16].

The prediction the post opens with is one operator's expectation: in three weeks most of the new installs will be a process on a box nobody watches, failing in a way nobody notices until a customer or a cron job does [17]. The recovery record behind it is a single journal entry from one night on the two servers he runs [4][2].

What to watch

  • Whether hermes-agent itself ships any supervision or restart handling, which would change what a fresh clone needs on top.
  • Whether the author publishes the third script, its line count, and whether the watchdog lock is per host or shared across both servers.
  • Whether a later journal entry records a night where the three-attempt budget ran out and a human was actually woken.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories