Download entrypoint.sh from Apache777/image: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/Apache777/image/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/Apache777/image/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/Apache777/image/resolve/main/entrypoint.sh
1.62 kB
| set -eu | |
| : "${SUPERVISORD_BIN:=/usr/bin/supervisord}" | |
| : "${SUPERVISOR_CONF_TEMPLATE:=/etc/supervisord.conf.template}" | |
| : "${APP_BINARY_PATH:=/app/app}" | |
| : "${RUNTIME_DIR:=/tmp/runtime}" | |
| : "${SUPERVISOR_CONF:=/etc/supervisord.conf}" | |
| : "${SUPERVISOR_PROGRAM_NAME:=app}" | |
| : "${OPEN_FILE_LIMIT:=65535}" | |
| export RUNTIME_DIR | |
| shell_quote() { | |
| printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\"'\"'/g")" | |
| } | |
| escape_sed_replacement() { | |
| printf '%s' "$1" | sed 's/[\/&]/\\&/g' | |
| } | |
| write_supervisord_conf() { | |
| mkdir -p "$(dirname "$SUPERVISOR_CONF")" | |
| app_program_name=$(escape_sed_replacement "$SUPERVISOR_PROGRAM_NAME") | |
| sed \ | |
| -e "s/__APP_PROGRAM__/$app_program_name/g" \ | |
| "$SUPERVISOR_CONF_TEMPLATE" > "$SUPERVISOR_CONF" | |
| } | |
| write_run_app_script() { | |
| run_app_script="$RUNTIME_DIR/run-app.sh" | |
| { | |
| printf '#!/bin/sh\n' | |
| printf 'set -eu\n' | |
| printf 'exec "%s"' "$APP_BINARY_PATH" | |
| for arg in "$@"; do | |
| printf ' %s' "$(shell_quote "$arg")" | |
| done | |
| printf '\n' | |
| } > "$run_app_script" | |
| chmod +x "$run_app_script" | |
| } | |
| prepare_runtime_environment() { | |
| ulimit -n "$OPEN_FILE_LIMIT" | |
| mkdir -p "$RUNTIME_DIR" | |
| rm -f "$RUNTIME_DIR/supervisor.sock" "$RUNTIME_DIR/supervisord.pid" | |
| } | |
| validate_app_binary_or_exit() { | |
| if [ ! -x "$APP_BINARY_PATH" ]; then | |
| echo "错误: APP_BINARY_PATH 指向的文件不存在或不可执行: $APP_BINARY_PATH" >&2 | |
| exit 1 | |
| fi | |
| } | |
| start_supervisord() { | |
| exec "$SUPERVISORD_BIN" -c "$SUPERVISOR_CONF" | |
| } | |
| main() { | |
| prepare_runtime_environment | |
| validate_app_binary_or_exit | |
| write_supervisord_conf | |
| write_run_app_script "$@" | |
| start_supervisord | |
| } | |
| main "$@" | |