prop/bin/notebook
Graham McIntire 3cc4301855 Auto-deploy analysis notebook as Livebook app
Add app_settings metadata to notebook and set LIVEBOOK_APPS_PATH
so it shows up under Apps on the Livebook home page.
2026-04-07 11:15:49 -05:00

41 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# Start Phoenix + Livebook together. Livebook attaches to the Phoenix node
# and gets full access to Repo, Scorer, Weather, etc.
#
# Usage: bin/notebook
# Then open http://localhost:8081
set -e
COOKIE="microwaveprop_nb"
NODE="prop@$(hostname -s)"
PORT="${LIVEBOOK_PORT:-8081}"
echo "Starting Phoenix on :4000 and Livebook on :${PORT}..."
echo "Livebook will be at http://localhost:${PORT}"
echo ""
# Start Phoenix in background with a node name
elixir --sname prop --cookie "$COOKIE" -S mix phx.server &
PHOENIX_PID=$!
# Wait for the node to come up
sleep 3
# Start Livebook attached to the Phoenix node
# LIVEBOOK_APPS_PATH makes notebooks show up under "Apps" on the home page
LIVEBOOK_HOME="$(pwd)/notebooks" \
LIVEBOOK_APPS_PATH="$(pwd)/notebooks" \
LIVEBOOK_APPS_PATH_HUB_ID="personal-hub" \
livebook server \
--port "$PORT" \
--default-runtime "attached:${NODE}:${COOKIE}" &
LIVEBOOK_PID=$!
# Trap ctrl-c to kill both
trap "kill $PHOENIX_PID $LIVEBOOK_PID 2>/dev/null; exit" INT TERM
echo "Phoenix PID: $PHOENIX_PID, Livebook PID: $LIVEBOOK_PID"
echo "Press Ctrl-C to stop both."
wait