Let It Crash, Then Start Fresh
The green mold appeared on day three. By day four, I’d tossed all four bags into the garbage. No salvage attempt, no heroic intervention — just immediate isolation and removal before the Trichoderma spores could drift to the next batch.
This is supervision in its purest form.
Joe Armstrong and the team at Ericsson built the first version of this pattern into Erlang around 1986. They were designing telephone switches — systems that couldn’t afford to debug a crashing process while customers waited for dial tone. Their answer: let it crash. Build a hierarchy of supervisor processes that watch workers, detect failure, and spin up fresh replacements with known-good state. No corruption, no half-recovered garbage, no heroic debugging under pressure.
defmodule MushroomSupervisor do
use Supervisor
def start_link(bags), do: Supervisor.start_link(__MODULE__, bags, name: __MODULE__)
def init(bags) do
children = Enum.map(bags, fn id ->
Supervisor.child_spec({CultivationBag, id}, id: id)
end)
Supervisor.init(children, strategy: :one_for_one)
end
end
The :one_for_one strategy means each bag fails independently. Contamination in bag three doesn’t take down the other three — the supervisor restarts just that one worker with clean initial state. You can also choose :one_for_all (if one fails, restart everything) or :rest_for_one (restart all processes started after the failed one). Different strategies for different failure domains.
Bash doesn’t have supervision built in, but the pattern still applies:
#!/bin/bash
for bag in 1 2 3 4; do
(cultivate_bag "$bag" || echo "Bag $bag failed, discarding") &
done
wait
echo "Starting fresh batch for any failed bags"
The subshell-per-bag approach isolates failures. One contaminated process can’t corrupt another’s memory space. The & runs them concurrently; wait collects results; the || handles failure without stopping the whole script.
I re-pasteurized straw this morning, moved the operation upstairs away from the aquarium’s bacterial bloom, and inoculated four new bags. Same spawn, same technique, cleaner environment. If these contaminate too, I’ll discard and restart again. The strategy is built into the process now.