Standardize start/stop scripts and add mu2edaq-discovery support - #3
Open
normanajn wants to merge 2 commits into
Open
Standardize start/stop scripts and add mu2edaq-discovery support#3normanajn wants to merge 2 commits into
normanajn wants to merge 2 commits into
Conversation
- 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>
There was a problem hiding this comment.
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.shcontrol scripts. - Add
CRS_PORT_HTTPenvironment-variable port override with priority between YAML config and CLI flags. - Add a
mu2edaq_discovery.Responderstartup 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 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 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 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 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1, fixes #2.
start_diskwatcher.sh/stop_diskwatcher.shto the control room conventionstart-mu2edaq-diskwatcher.sh/stop-mu2edaq-diskwatcher.sh; old names kept as symlinks for one release.CRS_PORT_HTTPenv override (exported by the control roomcrs-applauncher) slots between YAML config and explicit CLI flags (default unchanged: 5002).mu2edaq_discovery.Responder(appdiskwatcher) 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