Files
insights/bin/start-go-service
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

108 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
#
# Starts up "live" local builds of the insights Go
# services for a faster local dev inner loop
#
# set exit strategy
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
# ensure we have a service name
if [ -z "${1:-}" ]; then
echo "ERROR missing required argument: Go service name" >&2
echo "Usage: bin/start-go-service <SERVICE_NAME>" >&2
exit 1
fi
GO_SVC="$1"
# set up env appropriate for each *known* service - add new ones here!
case "$GO_SVC" in
livestream)
# Download MaxMind DB if it doesn't exist
./bin/download-mmdb
# Core settings
export LIVESTREAM_DEBUG=true
export PORT="8666"
# Consumer settings (per-topic Kafka config)
export LIVESTREAM_CONSUMERS_EVENT_ENABLED=true
export LIVESTREAM_CONSUMERS_EVENT_BROKERS=localhost:9092
export LIVESTREAM_CONSUMERS_EVENT_TOPIC=events_plugin_ingestion
export LIVESTREAM_CONSUMERS_EVENT_GROUP_ID=livestream-dev
export LIVESTREAM_CONSUMERS_EVENT_SECURITY_PROTOCOL=PLAINTEXT
export LIVESTREAM_CONSUMERS_EVENT_SESSION_TIMEOUT_MS=6000
export LIVESTREAM_CONSUMERS_EVENT_HEARTBEAT_INTERVAL_MS=1000
export LIVESTREAM_CONSUMERS_EVENT_MAX_POLL_INTERVAL_MS=6000
export LIVESTREAM_CONSUMERS_SESSION_RECORDING_ENABLED=true
export LIVESTREAM_CONSUMERS_SESSION_RECORDING_BROKERS=localhost:9092
export LIVESTREAM_CONSUMERS_SESSION_RECORDING_TOPIC=session_recording_snapshot_item_events
export LIVESTREAM_CONSUMERS_SESSION_RECORDING_GROUP_ID=livestream-dev-session-recordings
export LIVESTREAM_CONSUMERS_SESSION_RECORDING_SECURITY_PROTOCOL=PLAINTEXT
export LIVESTREAM_CONSUMERS_NOTIFICATION_ENABLED=true
export LIVESTREAM_CONSUMERS_NOTIFICATION_BROKERS=localhost:9092
export LIVESTREAM_CONSUMERS_NOTIFICATION_TOPIC=notification_events
export LIVESTREAM_CONSUMERS_NOTIFICATION_GROUP_ID=livestream-dev-notifications
export LIVESTREAM_CONSUMERS_NOTIFICATION_SECURITY_PROTOCOL=PLAINTEXT
export LIVESTREAM_REDIS_ADDRESS=localhost
export LIVESTREAM_REDIS_PORT=6399
export LIVESTREAM_REDIS_TLS=false
export LIVESTREAM_REDIS_USE_PUB_SUB=true
# MMDB path, relative to livestream directory where air runs
export LIVESTREAM_MMDB_PATH=../share/GeoLite2-City.mmdb
# Redis (needed for real-time notifications SSE endpoint)
export LIVESTREAM_REDIS_URL="redis://localhost:6379"
# JWT secret
export LIVESTREAM_JWT_SECRET="<randomly generated secret key>"
# ensure we're in the livestream directory for air
cd livestream
;;
*)
echo "ERROR unknown Go service '$GO_SVC' - please register in: $0" >&2
exit 1
;;
esac
# check if air is available for hot reloading
if command -v air &>/dev/null; then
USE_AIR=true
else
USE_AIR=false
echo -e "\n\033[33mWarning: 'air' not found. Running without hot reload.\033[0m"
echo -e "Install air for hot reloading: go install github.com/air-verse/air@latest\n"
fi
# ensure the service restarts if it crashes in dev
sleep 1
while true; do
if ! ps -p ${GO_PID:-} &>/dev/null; then
if [ "$USE_AIR" = true ]; then
air &
else
go run . &
fi
export GO_PID=$!
echo -e "\n\033[47m>>\033[0m Restarted '$GO_SVC' with PID $GO_PID\n"
fi
# restart subprocess if it fails without bin/start shutdown
set +e
wait $GO_PID
set -e
sleep 3
done
echo -e "\n\033[47m>>\033[0m Shut down '$GO_SVC'\n"
exit 0