Skip to content

Standardize start/stop scripts and add mu2edaq-discovery support - #3

Open
normanajn wants to merge 2 commits into
mainfrom
controlroom-integration
Open

Standardize start/stop scripts and add mu2edaq-discovery support#3
normanajn wants to merge 2 commits into
mainfrom
controlroom-integration

Conversation

@normanajn

Copy link
Copy Markdown
Contributor

Fixes #1, fixes #2.

  • Renames start_diskwatcher.sh/stop_diskwatcher.sh to the control room convention start-mu2edaq-diskwatcher.sh/stop-mu2edaq-diskwatcher.sh; old names kept as symlinks for one release.
  • CRS_PORT_HTTP env override (exported by the control room crs-app launcher) slots between YAML config and explicit CLI flags (default unchanged: 5002).
  • Announces via mu2edaq_discovery.Responder (app diskwatcher) just before the Flask server starts. Optional dependency; without it the daemon logs a note and runs normally.

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

🤖 Generated with Claude Code

- Rename start_diskwatcher.sh/stop_diskwatcher.sh to dashed convention;
  old names kept as symlinks for one release (fixes #1)
- Honor CRS_PORT_HTTP env override (between YAML and CLI in precedence)
- Announce via mu2edaq-discovery before serving; optional dependency
  (fixes #2)

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

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

This PR updates the Diskwatcher control-room integration by standardizing start/stop script names, adding a CRS_PORT_HTTP environment override for the Flask port, and introducing optional mu2edaq-discovery announcement support.

Changes:

  • Add start-mu2edaq-diskwatcher.sh / stop-mu2edaq-diskwatcher.sh control scripts.
  • Add CRS_PORT_HTTP environment-variable port override with priority between YAML config and CLI flags.
  • Add a mu2edaq_discovery.Responder startup announcement (currently started before the HTTP socket is bound and not stopped on shutdown).

Reviewed changes

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

File Description
start-mu2edaq-diskwatcher.sh New start script entrypoint following dashed naming convention.
stop-mu2edaq-diskwatcher.sh New stop script entrypoint following dashed naming convention.
diskwatcher.py Adds CRS_PORT_HTTP override and discovery announcement at startup.
requirements.txt Adds mu2edaq-discovery dependency via Git URL.

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

Comment thread diskwatcher.py
Comment on lines +1300 to +1302
# Control room launcher env override (between YAML and CLI in priority)
if os.environ.get("CRS_PORT_HTTP"): WEB_PORT = int(os.environ["CRS_PORT_HTTP"])

Comment thread diskwatcher.py
Comment on lines +1340 to 1350
# Announce via mu2edaq-discovery (optional dependency).
try:
from mu2edaq_discovery import Responder
Responder(name="Disk Watcher", app="diskwatcher",
port=WEB_PORT, scheme="http").start()
except ImportError:
print("[Discovery] mu2edaq-discovery not installed; discovery disabled")

# Start Flask (werkzeug development server)
app.run(host=WEB_HOST, port=WEB_PORT, use_reloader=False,
threaded=True)
Comment thread start-mu2edaq-diskwatcher.sh Outdated
Comment on lines +10 to +16
# Start the Diskwatcher
#python diskwatcher.py --config $CONFIG_FILE --daemon
python diskwatcher.py --config $CONFIG_FILE
if [ $? -eq 0 ]; then
echo "Diskwatcher started successfully"
echo "Diskwatcher PID: $(cat ${CONFIG_FILE%.yaml}.pid)"
else
Comment thread start-mu2edaq-diskwatcher.sh Outdated
Comment on lines +3 to +4
source ./venv/bin/activate
export PYTHONPATH=./src:$PYTHONPATH
Comment on lines +3 to +9
# This script is used to stop the Diskwatcher. It sends a shutdown signal to the server,
# which will then cleanly shut down.
#
# We start with a simple curl command to send a shutdown request to the server's API endpoint.
# If this fails then we resort to killing the process directly.
#
# We start with a kill and then do a kill -9 if the process does not terminate within a reasonable time frame.
Comment on lines +14 to +26
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
echo "Using Diskwatcher PID from file: $PID"
echo "Attempting to stop Diskwatcher with PID: $PID"
kill $PID 2>/dev/null || true
sleep 5
if kill -0 $PID 2>/dev/null; then
echo "Diskwatcher did not shut down cleanly, killing forcefully."
kill -9 $PID 2>/dev/null || true
else
echo "Diskwatcher stopped successfully."
fi
rm -f "$PID_FILE"
@@ -0,0 +1,20 @@
#!/bin/bash
A relocated venv makes 'source venv/bin/activate' prepend a dead path,
so bare 'python' silently falls back to the system interpreter (Python 2
on macOS), failing with a non-ASCII/encoding SyntaxError. Resolve paths
from the script location and exec $SCRIPT_DIR/venv/bin/python directly,
with a clear error if the venv is missing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add mu2edaq-discovery auto-discovery support Rename start_diskwatcher.sh / stop_diskwatcher.sh to dashed convention

2 participants