lmjtfy.git / tools / wrangler-dev
wrangler-dev22 lines · 822 B · raw
1#!/usr/bin/env bash
2# The Worker under `wrangler dev`, for pitchfork's `worker` daemon (see
3# pitchfork.toml).
4#
5# A dev server that exits without being asked to has failed, whatever status
6# it left with: wrangler's wrapper exits 0 when the runtime under it is
7# killed (measured 2026-10-02), and pitchfork retries only a failure. So any
8# exit that pitchfork did not ask for is reported as status 1.
9#
10# Stopping this script (SIGTERM/SIGINT from pitchfork) stops wrangler the
11# same way and waits for it.
12set -uo pipefail
13cd "$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
14
15child=""
16trap 'kill -TERM "$child" 2>/dev/null; wait "$child" 2>/dev/null; exit 0' TERM INT
17
18lmjtfy-wrangler apps/lmjtfy dev --port 8787 &
19child=$!
20wait "$child"
21echo "wrangler dev exited with status $? without being asked to" >&2
22exit 1