| 1 | #!/bin/bash |
| 2 | |
| 3 | # Define the prefix for environment variables to look for |
| 4 | PREFIX="SM_VLLM_" |
| 5 | ARG_PREFIX="--" |
| 6 | |
| 7 | # Initialize an array for storing the arguments |
| 8 | # port 8080 required by sagemaker, https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-code-container-response |
| 9 | ARGS=(--port 8080) |
| 10 | |
| 11 | # Loop through all environment variables |
| 12 | while IFS='=' read -r key value; do |
| 13 | # Remove the prefix from the key, convert to lowercase, and replace underscores with dashes |
| 14 | arg_name=$(echo "${key#"${PREFIX}"}" | tr '[:upper:]' '[:lower:]' | tr '_' '-') |
| 15 | |
| 16 | # Add the argument name and value to the ARGS array |
| 17 | ARGS+=("${ARG_PREFIX}${arg_name}") |
| 18 | if [ -n "$value" ]; then |
| 19 | ARGS+=("$value") |
| 20 | fi |
| 21 | done < <(env | grep "^${PREFIX}") |
| 22 | |
| 23 | # Pass the collected arguments to the main entrypoint |
| 24 | exec standard-supervisor vllm serve "${ARGS[@]}" |