Skip to content

Add start/stop wrapper scripts with port overrides and discovery sidecar - #3

Open
normanajn wants to merge 1 commit into
mainfrom
controlroom-integration
Open

Add start/stop wrapper scripts with port overrides and discovery sidecar#3
normanajn wants to merge 1 commit into
mainfrom
controlroom-integration

Conversation

@normanajn

Copy link
Copy Markdown
Contributor

Fixes #1, fixes #2.

  • Adds start-mu2edaq-trigger-scalers.sh: locates build/trigger-scalers, inherits DISPLAY from the invoking VNC session, and maps the control room CRS_PORT_UDP / CRS_PORT_ZMQ env overrides onto the binary's existing --udp-port / --zmq-port options (no C++ changes needed — the CLI plumbing was already there). The control room app inventory assigns UDP 5557 to avoid the mu2edaq-dashboard ZMQ 5555 clash; repo defaults are unchanged.
  • Adds stop-mu2edaq-trigger-scalers.sh (PID-file kill, by-name fallback, no-op success).
  • Discovery runs as a Python mu2edaq_discovery.Responder sidecar started by the start script — the interim approach from Add discovery support (blocked on mu2edaq-discovery C++ library) #2 until the native C++ library lands in mu2edaq-discovery (protocol is plain JSON over UDP, so a future QUdpSocket port is mechanical). The sidecar exits silently when the package isn't installed; the stop script kills it before the app so discovery never advertises a dead display.

Part of the control room integration (mu2edaq-controlroom-setup).

🤖 Generated with Claude Code

- start-mu2edaq-trigger-scalers.sh locates the built binary, inherits
  DISPLAY, and maps CRS_PORT_UDP/CRS_PORT_ZMQ onto the existing
  --udp-port/--zmq-port options (control room assigns UDP 5557 to avoid
  the dashboard ZMQ 5555 clash) (fixes #1)
- Python mu2edaq-discovery responder runs as a sidecar until the native
  C++ library exists; stop kills the sidecar first (fixes #2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 12, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds operational wrapper scripts to start/stop the trigger-scalers Qt GUI with control-room port overrides and an interim service-discovery sidecar, supporting control room integration without requiring C++ changes.

Changes:

  • Add start-mu2edaq-trigger-scalers.sh to locate/run build/trigger-scalers, map CRS_PORT_UDP/CRS_PORT_ZMQ to CLI overrides, and launch a Python discovery responder sidecar.
  • Add stop-mu2edaq-trigger-scalers.sh to stop the GUI and sidecar via pidfiles with a by-name fallback.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
start-mu2edaq-trigger-scalers.sh Starts the GUI with env-driven port overrides and launches a Python discovery sidecar.
stop-mu2edaq-trigger-scalers.sh Stops the sidecar first, then the GUI, using pidfiles and a name-based fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +12
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PID_FILE="/tmp/trigger-scalers.pid"
DISC_PID_FILE="/tmp/trigger-scalers-responder.pid"
Comment on lines +30 to +32
nohup "$BINARY" "${ARGS[@]}" "$@" >> /tmp/trigger-scalers.log 2>&1 &
echo $! > "$PID_FILE"
echo "Trigger Scalers started (PID $(cat "$PID_FILE"))."
Comment on lines +36 to +49
python3 - "${CRS_PORT_UDP:-5555}" "${CRS_PORT_ZMQ:-5556}" >/dev/null 2>&1 <<'PYEOF' &
import signal, sys
try:
from mu2edaq_discovery import Responder
except ImportError:
sys.exit(0)
r = Responder(name="Trigger Scalers", app="trigger-scalers",
port=int(sys.argv[1]), scheme="udp",
meta={"zmq_port": sys.argv[2]})
r.start()
signal.signal(signal.SIGTERM, lambda *a: sys.exit(0))
signal.pause()
PYEOF
echo $! > "$DISC_PID_FILE"
Comment on lines +5 to +6
PID_FILE="/tmp/trigger-scalers.pid"
DISC_PID_FILE="/tmp/trigger-scalers-responder.pid"
rm -f "$PID_FILE"
echo "Trigger Scalers stopped."
else
PIDS=$(pgrep -x "trigger-scalers" || true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants