-
Notifications
You must be signed in to change notification settings - Fork 12
Improve grpc reliability #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Debug script for Dagster gRPC connectivity issues in Fly.io deployment | ||
| echo "🔍 Dagster gRPC Connectivity Debugger" | ||
| echo "=======================================" | ||
|
|
||
| # Check environment | ||
| echo "📋 Environment Information:" | ||
| echo "DAGSTER_HOME: ${DAGSTER_HOME:-not set}" | ||
| echo "DAGSTER_CODE_SERVER_HOST: ${DAGSTER_CODE_SERVER_HOST:-not set}" | ||
| echo "PYTHONPATH: ${PYTHONPATH:-not set}" | ||
| echo "" | ||
|
|
||
| # Check if processes are running | ||
| echo "🔄 Process Status:" | ||
| echo "Code server (port 4000):" | ||
| if pgrep -f "dagster code-server" > /dev/null; then | ||
| echo " ✅ Code server process is running (PID: $(pgrep -f 'dagster code-server'))" | ||
| else | ||
| echo " ❌ Code server process is not running" | ||
| fi | ||
|
|
||
| echo "Webserver (port 3000):" | ||
| if pgrep -f "dagster-webserver" > /dev/null; then | ||
| echo " ✅ Webserver process is running (PID: $(pgrep -f 'dagster-webserver'))" | ||
| else | ||
| echo " ❌ Webserver process is not running" | ||
| fi | ||
|
|
||
| echo "Daemon:" | ||
| if pgrep -f "dagster-daemon" > /dev/null; then | ||
| echo " ✅ Daemon process is running (PID: $(pgrep -f 'dagster-daemon'))" | ||
| else | ||
| echo " ❌ Daemon process is not running" | ||
| fi | ||
| echo "" | ||
|
|
||
| # Check ports | ||
| echo "🌐 Port Status:" | ||
| echo "Port 4000 (code server):" | ||
| if netstat -tuln 2>/dev/null | grep ":4000" > /dev/null; then | ||
|
||
| echo " ✅ Port 4000 is listening" | ||
| netstat -tuln | grep ":4000" | ||
| else | ||
| echo " ❌ Port 4000 is not listening" | ||
| fi | ||
|
|
||
| echo "Port 3000 (webserver):" | ||
| if netstat -tuln 2>/dev/null | grep ":3000" > /dev/null; then | ||
| echo " ✅ Port 3000 is listening" | ||
| netstat -tuln | grep ":3000" | ||
| else | ||
| echo " ❌ Port 3000 is not listening" | ||
| fi | ||
| echo "" | ||
|
|
||
| # Test gRPC health check | ||
| echo "💓 gRPC Health Check:" | ||
| if dagster api grpc-health-check -p 4000 2>/dev/null; then | ||
| echo " ✅ gRPC health check passed" | ||
| else | ||
| echo " ❌ gRPC health check failed" | ||
| echo " Detailed error:" | ||
| dagster api grpc-health-check -p 4000 2>&1 | head -5 | ||
| fi | ||
| echo "" | ||
|
|
||
| # Test workspace loading | ||
| echo "📚 Workspace Configuration:" | ||
| if [ -f "$DAGSTER_HOME/workspace.yaml" ]; then | ||
| echo " ✅ Workspace file exists: $DAGSTER_HOME/workspace.yaml" | ||
| echo " Content preview:" | ||
| head -15 "$DAGSTER_HOME/workspace.yaml" | sed 's/^/ /' | ||
| else | ||
| echo " ❌ Workspace file not found: $DAGSTER_HOME/workspace.yaml" | ||
| fi | ||
| echo "" | ||
|
|
||
| # Check log files for errors | ||
| echo "📄 Recent Log Entries:" | ||
| for logfile in /tmp/code_server.log /tmp/webserver.log /tmp/daemon.log; do | ||
| if [ -f "$logfile" ]; then | ||
| echo " 📄 $logfile (last 10 lines):" | ||
| tail -10 "$logfile" 2>/dev/null | sed 's/^/ /' || echo " Could not read log file" | ||
| echo "" | ||
| fi | ||
| done | ||
|
|
||
| # Test direct connection | ||
| echo "🔌 Direct Connection Test:" | ||
| if command -v telnet >/dev/null 2>&1; then | ||
| echo " Testing localhost:4000..." | ||
| timeout 5 telnet localhost 4000 2>/dev/null && echo " ✅ Connection successful" || echo " ❌ Connection failed" | ||
| elif command -v nc >/dev/null 2>&1; then | ||
| echo " Testing localhost:4000..." | ||
| timeout 5 nc -z localhost 4000 2>/dev/null && echo " ✅ Connection successful" || echo " ❌ Connection failed" | ||
| else | ||
| echo " ⚠️ No telnet or nc available for connection testing" | ||
| fi | ||
| echo "" | ||
|
|
||
| # System resources | ||
| echo "💾 System Resources:" | ||
| echo " Memory usage:" | ||
| free -h 2>/dev/null | head -2 | sed 's/^/ /' || echo " Memory info not available" | ||
| echo " Disk usage for /data:" | ||
| df -h /data 2>/dev/null | sed 's/^/ /' || echo " Disk info not available" | ||
| echo "" | ||
|
|
||
| echo "🏁 Debug complete!" | ||
| echo "" | ||
| echo "💡 Common fixes:" | ||
| echo " 1. Restart the deployment: fly deploy" | ||
| echo " 2. Check resource limits in fly.toml" | ||
| echo " 3. Review logs: fly logs" | ||
| echo " 4. Scale up if memory/CPU constrained: fly scale memory 8192" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Anomstack Startup Script for Fly.io | ||||||||||||||||||||||||||||||||||||||||||||||
| # Anomstack Startup Script for Fly.io with improved gRPC connectivity | ||||||||||||||||||||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "🚀 Starting Anomstack services..." | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -24,35 +24,132 @@ ADMIN_PASSWORD="${ANOMSTACK_ADMIN_PASSWORD:-anomstack2024}" | |||||||||||||||||||||||||||||||||||||||||||||
| htpasswd -bc /etc/nginx/.htpasswd "$ADMIN_USERNAME" "$ADMIN_PASSWORD" | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "✅ Authentication configured for user: $ADMIN_USERNAME" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Function to check if code server is healthy | ||||||||||||||||||||||||||||||||||||||||||||||
| check_code_server_health() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local retries=0 | ||||||||||||||||||||||||||||||||||||||||||||||
| local max_retries=30 | ||||||||||||||||||||||||||||||||||||||||||||||
| while [ $retries -lt $max_retries ]; do | ||||||||||||||||||||||||||||||||||||||||||||||
| if dagster api grpc-health-check -p 4000 >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "✅ Code server is healthy" | ||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "⏳ Waiting for code server to be ready... (attempt $((retries + 1))/$max_retries)" | ||||||||||||||||||||||||||||||||||||||||||||||
| sleep 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| retries=$((retries + 1)) | ||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Code server failed to start after $max_retries attempts" | ||||||||||||||||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Function to start process with retry logic | ||||||||||||||||||||||||||||||||||||||||||||||
| start_process_with_retry() { | ||||||||||||||||||||||||||||||||||||||||||||||
| local name=$1 | ||||||||||||||||||||||||||||||||||||||||||||||
| local command=$2 | ||||||||||||||||||||||||||||||||||||||||||||||
| local logfile=$3 | ||||||||||||||||||||||||||||||||||||||||||||||
| local max_retries=3 | ||||||||||||||||||||||||||||||||||||||||||||||
| local retry=0 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| while [ $retry -lt $max_retries ]; do | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "🔧 Starting $name (attempt $((retry + 1))/$max_retries)..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nohup $command > $logfile 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| local pid=$! | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "$name PID: $pid" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Give it a moment to crash if it's going to | ||||||||||||||||||||||||||||||||||||||||||||||
| sleep 3 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if kill -0 $pid 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "✅ $name started successfully" | ||||||||||||||||||||||||||||||||||||||||||||||
| echo $pid | ||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "⚠️ $name failed to start, retrying..." | ||||||||||||||||||||||||||||||||||||||||||||||
| retry=$((retry + 1)) | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Failed to start $name after $max_retries attempts" | ||||||||||||||||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "🔧 Starting code server..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nohup dagster code-server start -h 0.0.0.0 -p 4000 -f anomstack/main.py > /tmp/code_server.log 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| CODE_SERVER_PID=$! | ||||||||||||||||||||||||||||||||||||||||||||||
| CODE_SERVER_PID=$(start_process_with_retry "Code Server" "dagster code-server start -h 0.0.0.0 -p 4000 -f anomstack/main.py" "/tmp/code_server.log") | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Failed to start code server, exiting" | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "⏳ Waiting for code server to start..." | ||||||||||||||||||||||||||||||||||||||||||||||
| sleep 10 | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "⏳ Waiting for code server to be ready..." | ||||||||||||||||||||||||||||||||||||||||||||||
| if ! check_code_server_health; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Code server health check failed, exiting" | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "🌐 Starting webserver..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nohup dagster-webserver -h 0.0.0.0 -p 3000 -w /opt/dagster/dagster_home/workspace.yaml > /tmp/webserver.log 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| WEBSERVER_PID=$! | ||||||||||||||||||||||||||||||||||||||||||||||
| WEBSERVER_PID=$(start_process_with_retry "Webserver" "dagster-webserver -h 0.0.0.0 -p 3000 -w /opt/dagster/dagster_home/workspace.yaml" "/tmp/webserver.log") | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Failed to start webserver, exiting" | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "⚙️ Starting daemon..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nohup dagster-daemon run -w /opt/dagster/dagster_home/workspace.yaml > /tmp/daemon.log 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| DAEMON_PID=$! | ||||||||||||||||||||||||||||||||||||||||||||||
| DAEMON_PID=$(start_process_with_retry "Daemon" "dagster-daemon run -w /opt/dagster/dagster_home/workspace.yaml" "/tmp/daemon.log") | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Failed to start daemon, exiting" | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "📊 Starting dashboard..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nohup uvicorn dashboard.app:app --host 0.0.0.0 --port 8080 > /tmp/dashboard.log 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| DASHBOARD_PID=$! | ||||||||||||||||||||||||||||||||||||||||||||||
| DASHBOARD_PID=$(start_process_with_retry "Dashboard" "uvicorn dashboard.app:app --host 0.0.0.0 --port 8080" "/tmp/dashboard.log") | ||||||||||||||||||||||||||||||||||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "❌ Failed to start dashboard, exiting" | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "🌐 Starting nginx reverse proxy..." | ||||||||||||||||||||||||||||||||||||||||||||||
| nginx -t && nginx -g "daemon off;" > /tmp/nginx.log 2>&1 & | ||||||||||||||||||||||||||||||||||||||||||||||
| nginx -t && nginx -g "daemon off;" & | ||||||||||||||||||||||||||||||||||||||||||||||
| NGINX_PID=$! | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+110
to
111
|
||||||||||||||||||||||||||||||||||||||||||||||
| nginx -t && nginx -g "daemon off;" & | |
| NGINX_PID=$! | |
| NGINX_PID=$(start_process_with_retry "Nginx" "nginx -t && nginx -g 'daemon off;'" "/tmp/nginx.log") | |
| if [ $? -ne 0 ]; then | |
| echo "❌ Failed to start nginx, exiting" | |
| exit 1 | |
| fi |
Copilot
AI
Jul 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The monitoring loop doesn't handle the case where start_process_with_retry fails and returns a non-zero exit code instead of a PID. This could cause the kill -0 command to fail with an invalid PID, potentially breaking the monitoring logic.
| CODE_SERVER_PID=$(start_process_with_retry "Code Server" "dagster code-server start -h 0.0.0.0 -p 4000 -f anomstack/main.py" "/tmp/code_server.log") | |
| fi | |
| if ! kill -0 $WEBSERVER_PID 2>/dev/null; then | |
| echo "❌ Webserver crashed, restarting..." | |
| WEBSERVER_PID=$(start_process_with_retry "Webserver" "dagster-webserver -h 0.0.0.0 -p 3000 -w /opt/dagster/dagster_home/workspace.yaml" "/tmp/webserver.log") | |
| CODE_SERVER_PID=$(start_process_with_retry "Code Server" "dagster code-server start -h 0.0.0.0 -p 4000 -f anomstack/main.py" "/tmp/code_server.log") | |
| if ! [[ $CODE_SERVER_PID =~ ^[0-9]+$ ]]; then | |
| echo "❌ Failed to restart Code Server: Invalid PID returned" | |
| CODE_SERVER_PID="" | |
| continue | |
| fi | |
| fi | |
| if ! kill -0 $WEBSERVER_PID 2>/dev/null; then | |
| echo "❌ Webserver crashed, restarting..." | |
| WEBSERVER_PID=$(start_process_with_retry "Webserver" "dagster-webserver -h 0.0.0.0 -p 3000 -w /opt/dagster/dagster_home/workspace.yaml" "/tmp/webserver.log") | |
| if ! [[ $WEBSERVER_PID =~ ^[0-9]+$ ]]; then | |
| echo "❌ Failed to restart Webserver: Invalid PID returned" | |
| WEBSERVER_PID="" | |
| continue | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The 5-minute ping interval seems excessive for a single-container deployment and conflicts with the 30-second keepalive time. Consider reducing this value to maintain consistency with other keepalive settings.