Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
35 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Money in billing's messages reads to the cent, and the deploy reads migrations again after a failure1#!/usr/bin/env bash
2# Starts the status page of a self-hosted g1t (apps/status) in a workerd of
3# its own on :8788, so it stays up when the site does not. Its database
4# lives on its own volume. `wrangler dev` runs no crons, so a loop here
5# asks for a round of checks every minute instead.
6set -euo pipefail
7
8cd "$(dirname "$0")"
9DATA="${G1T_DATA:-/data}"
10STATE="$DATA/state"
11GENERATED="$DATA/generated"
12WRANGLER="$(cd ../.. && pwd)/node_modules/.bin/wrangler"
13mkdir -p "$STATE"
14
15# configs.mjs writes every config; only the status page's is used here.
16# It needs nothing secret, so placeholders stand in for the site's keys.
17GITSTORE_SECRET="${GITSTORE_SECRET:-unused}" node configs.mjs "$GENERATED" >/dev/null
18cd "$GENERATED"
19
20echo "Migrating g1t-status"
21"$WRANGLER" d1 migrations apply g1t-status --local --persist-to "$STATE" -c g1t-status.json >/dev/null
22
23# Every minute, the cron's work: check each part and keep the result.
24# (The image has Node but no curl.)
25node -e '
26const tick = () => fetch("http://127.0.0.1:8788/__scheduled?cron=*+*+*+*+*").catch(() => {});
27setTimeout(() => { tick(); setInterval(tick, 60_000); }, 15_000);
28' &
29
30echo "The status page is starting on http://localhost:${STATUS_PORT:-8788}"
31exec "$WRANGLER" dev -c g1t-status.json \
32 --ip 0.0.0.0 --port 8788 \
33 --persist-to "$STATE" \
34 --test-scheduled \
35 --show-interactive-dev-session=false

This file's history is long; its oldest lines are credited to the oldest commit read.