Answers "do we have to start the server in terminal?" -- no. install.sh installs
deps and registers a launchd agent with RunAtLoad + KeepAlive, so the daemon
starts at login and comes back if it dies. Verified by killing the process: back
up and serving within seconds under a new pid. Deploying to the M3 Air is then:
git clone ssh://git@100.71.119.27:222/monster/yourovo.git
cd yourovo/mac && ./install.sh
Also revises the A/B/C recommendation. Grepping the extension shows it calls only
six endpoints: /status, /write-tag, /read-tag (all served here) plus /weight,
/scale/start, /scale/stop (the DYMO M10 postal scale, Node-only). So the gap to a
single service is the scale and nothing else -- which makes option B (Node on
:7791 with this one proxying) the wrong trade: one URL but two processes, two
dependency stacks and two things to keep alive, against a stated goal of one
button on a second machine.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
2.4 KiB
Bash
Executable File
80 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# One-command install on a fresh Apple Silicon Mac.
|
|
#
|
|
# git clone ssh://git@100.71.119.27:222/monster/yourovo.git
|
|
# cd yourovo/mac && ./install.sh
|
|
#
|
|
# Installs dependencies, then registers a launchd agent so the daemon starts at login
|
|
# and restarts itself if it dies. No Terminal needed after this, ever.
|
|
#
|
|
# Re-runnable: pulls the latest commit and reloads the agent.
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
HERE="$(pwd -P)"
|
|
LABEL="com.pricegod.labeld"
|
|
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
|
|
LOG="$HOME/Library/Logs/pricegod-labeld.log"
|
|
|
|
case "${1:-install}" in
|
|
uninstall)
|
|
launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true
|
|
rm -f "$PLIST"
|
|
echo "removed $LABEL"
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
echo "==> updating from git"
|
|
git -C "$HERE/.." pull --ff-only 2>/dev/null || echo " (skipped -- not a clean fast-forward)"
|
|
|
|
echo "==> dependencies"
|
|
./setup.sh
|
|
|
|
echo "==> launchd agent"
|
|
mkdir -p "$(dirname "$PLIST")" "$(dirname "$LOG")"
|
|
cat > "$PLIST" <<PLISTEOF
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key> <string>$LABEL</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>$HERE/venv/bin/python</string>
|
|
<string>$HERE/daemon.py</string>
|
|
</array>
|
|
<key>WorkingDirectory</key> <string>$HERE</string>
|
|
<key>RunAtLoad</key> <true/>
|
|
<key>KeepAlive</key> <true/>
|
|
<key>ProcessType</key> <string>Interactive</string>
|
|
<key>StandardOutPath</key> <string>$LOG</string>
|
|
<key>StandardErrorPath</key> <string>$LOG</string>
|
|
</dict>
|
|
</plist>
|
|
PLISTEOF
|
|
|
|
launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true
|
|
launchctl bootstrap "gui/$(id -u)" "$PLIST"
|
|
launchctl kickstart -k "gui/$(id -u)/$LABEL"
|
|
|
|
echo "==> waiting for the daemon"
|
|
for i in $(seq 1 20); do
|
|
if curl -fsS -m 2 http://localhost:7790/ >/dev/null 2>&1; then
|
|
echo
|
|
curl -s http://localhost:7790/devices
|
|
echo
|
|
echo
|
|
echo "OK -- running on http://localhost:7790/ and will start at every login."
|
|
echo " logs: tail -f $LOG"
|
|
echo " restart: launchctl kickstart -k gui/$(id -u)/$LABEL"
|
|
echo " uninstall: ./install.sh uninstall"
|
|
exit 0
|
|
fi
|
|
sleep 0.5
|
|
done
|
|
|
|
echo "daemon did not come up -- check $LOG" >&2
|
|
tail -20 "$LOG" 2>/dev/null || true
|
|
exit 1
|