hubcio commented on code in PR #2178:
URL: https://github.com/apache/iggy/pull/2178#discussion_r2362761811


##########
scripts/run-csharp-examples-from-readme.sh:
##########
@@ -0,0 +1,210 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euo pipefail
+
+# Script to run Csharp examples from examples/csharp/README.md files
+# Usage: ./scripts/run-csharp-examples-from-readme.sh [OPTIONS]
+#
+# --csos   - Optional target OS (e.g., linux, darwin)
+# --csarch - Optional target architecture (e.g., amd64, arm64)
+# --target - Optional target architecture for rust (e.g., 
x86_64-unknown-linux-musl)
+#
+# This script will run all the commands from examples/csharp/README.md files
+# and check if they pass or fail.
+# If any command fails, it will print the command and exit with non-zero 
status.
+# If all commands pass, it will remove the log file and exit with zero status.
+#
+# Note: This script assumes that the iggy-server is not running and will start 
it in the background.
+#       It will wait until the server is started before running the commands.
+#       It will also terminate the server after running all the commands.
+#       Script executes every command in README files which is enclosed in 
backticks (`) and starts
+#       with `dotnet run --project src/xxx`. Other commands are ignored.
+#       Order of commands in README files is important as script will execute 
them from top to bottom.
+#
+
+readonly LOG_FILE="iggy-server.log"
+readonly PID_FILE="iggy-server.pid"
+readonly TIMEOUT=300
+
+# Get target architecture from argument or use default
+
+CSOS="" # chsarp target OS
+CSARCH="" # csharp target architecture
+TARGET="" # Iggy server target architecture
+
+while [[ $# -gt 0 ]]; do
+    case "$1" in
+        --csharpos)
+            CSOS="$2"
+            shift 2
+            ;;
+        --csharparch)
+            CSARCH="$2"
+            shift 2
+            ;;
+        --target)
+            TARGET="$2"
+            shift 2
+            ;;
+        *)
+            echo "Unknown option: $1"
+            echo "Usage: $0 [--csos CSOS] [--csarch CSARCH] [--target TARGET]"
+            exit 1
+            ;;
+    esac
+done
+
+# Remove old server data if present
+test -d local_data && rm -fr local_data
+test -e ${LOG_FILE} && rm ${LOG_FILE}
+test -e ${PID_FILE} && rm ${PID_FILE}
+
+# Check if server binary exists
+SERVER_BIN=""
+if [ -n "${TARGET}" ]; then
+    SERVER_BIN="target/${TARGET}/debug/iggy-server"
+else
+    SERVER_BIN="target/debug/iggy-server"
+fi
+
+if [ ! -f "${SERVER_BIN}" ]; then
+    echo "Error: Server binary not found at ${SERVER_BIN}"
+    echo "Please build the server binary before running this script:"
+    if [ -n "${TARGET}" ]; then
+        echo "  cargo build --target ${TARGET} --bin iggy-server"
+    else
+        echo "  cargo build --bin iggy-server"
+    fi
+    exit 1
+fi
+
+echo "Using server binary at ${SERVER_BIN}"
+
+# Run iggy server using the prebuilt binary
+echo "Starting server from ${SERVER_BIN}..."
+${SERVER_BIN} &>${LOG_FILE} &

Review Comment:
   change to `IGGY_ROOT_USERNAME=iggy IGGY_ROOT_PASSWORD=iggy ${SERVER_BIN} 
&>${LOG_FILE} &`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to